欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

京东移动端仿写

程序员文章站 2024-01-24 23:28:46
...

0x00 代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="css/normalize.css">
    <link rel="stylesheet" href="css/index.css">
    <title>Title</title>
</head>
<body>
    <header class="app">
        <ul>
            <li>
                <img src="images/close.png" alt="error,please call admin">
            </li>
            <li>
                <img src="images/logo.png" alt="error,please call admin">
            </li>
            <li>打开京东app,购物更简单</li>
            <li>立即打开</li>
        </ul>
    </header>
    <div class="search-wrap">
        <div class="search-btn"></div>
        <div class="search">
            <div class="jd-icon"></div>
            <div class="search-icon"></div>
            <input type="text" placeholder="苏泊尔电磁炉" class="search-input"/>
        </div>
        <div class="search-login">登录</div>
    </div>
    <div class="main-content">
        <div class="slider">
            <img src="upload/banner.dpg" alt="">
        </div>
        <div class="brand">
            <div>
                <a href="#">
                    <img src="upload/pic11.dpg" alt="">
                </a>
            </div>
            <div>
                <a href="#">
                    <img src="upload/pic22.dpg" alt="">
                </a>

            </div>
            <div>
                <a href="#">
                    <img src="upload/pic33.dpg" alt="">
                </a>

            </div>
        </div>
        <nav class="clearfix">
            <a href="">
                <img src="upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>

            <a href="">
                <img src="upload/nav2.webp" alt="">
                <span>京东超市</span>
            </a>

            <a href="">
                <img src="upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>

            <a href="">
                <img src="upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>

            <a href="">
                <img src="upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>

            <a href="">
                <img src="upload/nav3.webp" alt="">
                <span>京东超市</span>
            </a>

            <a href="">
                <img src="upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>

            <a href="">
                <img src="upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>

            <a href="">
                <img src="upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>

            <a href="">
                <img src="upload/nav1.webp" alt="">
                <span>京东超市</span>
            </a>

        </nav>
        <div class="news">
            <a href="#">
                <img src="upload/new1.dpg" alt="">
            </a>
            <a href="#">
                <img src="upload/new2.dpg" alt="">

            </a>
            <a href="#">
                <img src="upload/new3.dpg" alt="">

            </a>
        </div>
    </div>
</body>
</html>
body {
    width: 100%;
    min-width: 320px;
    max-width: 640px;
    margin: 0 auto;
    background: #fff;
    font-size: 14px;
    font-family: -apple-system, Helvetica, sans-serif;
    color: #666;
    line-height: 0;
}
.clearfix {
    *zoom: 1;
}
.clearfix::after {
    content: "";
    clear: both;
    display: block;
    height: 0;
    visibility: hidden;
}

/*顶部栏*/
.app {
    height: 45px;
}
.app ul {
    padding: 0;
    margin: 0;
}
.app ul li {
    list-style: none;
    float: left;
    background-color: #515151;
    height: 45px;
    line-height: 45px;
    text-align: center;
    color: #ffffff;
}
.app ul li:nth-child(1) {
    width: 8%;
}
.app ul li:nth-child(1) img {
    width: 10px;
}
.app ul li:nth-child(2) {
    width: 10%;
}
/*图片是行内块元素,会存在基线和文字不同无法对齐的情况,这里设置基线和文字对齐就可以了*/
.app ul li:nth-child(2) img{
    width: 30px;
    vertical-align: middle;
}
.app ul li:nth-child(3) {
    width: 57%;
}
.app ul li:nth-child(4) {
    width: 25%;
    background-color: rgb(246, 53, 21);
}
/*搜索栏*/
.search-wrap {
    height: 44px;
    width: 100%;
    line-height: 44px;
    position: fixed;
    max-width: 640px;
    min-width: 320px;
    /*解决块元素的塌陷问题*/
    overflow: hidden;
    background-color: transparent;
    color: #ffffff;
}
.search-btn {
    position: absolute;
    height: 44px;
    width: 40px;
    top: 0;
    left: 0;
}
.search-btn::before {
    content: "";
    display: block;
    height: 44px;
    width: 40px;
    background: url(../images/s-btn.png) no-repeat;
    background-size: 20px 18px;
    margin: 14px 0 0 15px;
}
/*注意,这里有外边距的合并问题,即块元素的塌陷问题*/
.search {
    height: 30px;
    margin: 7px 50px 0 50px;
    border-radius: 15px;
    background-color: #ffffff;
    position: relative;
}
.jd-icon {
    position: absolute;
    width: 20px;
    height: 15px;
    top: 8px;
    left: 13px;
    background: url("../images/jd.png") no-repeat;
    background-size: 20px 15px;
}
.jd-icon::after {
    content: '';
    position: absolute;
    display: block;
    width: 1px;
    height: 15px;
    right: -8px;
    background-color: #ccc;
}
.search-icon {
    position: absolute;
    top: 8px;
    left: 50px;
    width: 18px;
    height: 15px;
    background: url(../images/jd-sprites.png) no-repeat -81px 0;
    background-size: 200px auto;
}
.search-input {
    position: absolute;
    border: 0;
    background: 0 0;
    top: 7px;
    left: 70px;
    padding-left: 5px;
}
.search-login {
    position: absolute;
    height: 44px;
    width: 40px;
    top: 0;
    right: 0;
}
/*轮播图*/
.slider {
    border: 0;
}

.slider img {
    width: 100%;
}
/*品牌日*/
.brand {
    overflow: hidden;
    border-radius: 10px 10px 0 0;
}
.brand div {
    float: left;
    width: 33.33%;
}
.brand div img {
    width: 100%;
}
/*品牌日nav部分*/
nav a {
    float: left;
    width: 20%;
    text-align: center;
    text-decoration: none;
    color: #666;
}
nav a img {
    width: 40px;
    margin: 10px 0;
}
nav a span {
    display: block;
}
.news {
    margin-top: 20px;
}

.news img {
    width: 100%;
}

.news a {
    float: left;
    box-sizing: border-box;
}

.news a:nth-child(1) {
    width: 50%;
}

.news a:nth-child(n+2) {
    width: 25%;
    border-left: 1px solid #ccc;
}

0x01 效果

京东移动端仿写

相关标签: web css