移动端开发案例(流式布局)

移动端开发案例(流式布局)_第1张图片


"en">


    "UTF-8">
    "viewport" content="width=device-width, user-scalable=no, initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
    "stylesheet" href="css/normalize.css">
    "stylesheet" href="CSS/index.css">
    主页
    



    
"app">
  • "images/close.png" alt="">
  • "images/logo.png" alt="">
  • 打开京东APP,购物更轻松
  • 立即打开
"search-wrap">
"search-btn">
"search">
"jd-icon">
"sou">
"search-login"> 登陆
body {
     
    margin: 0 auto;
    width: 100%;
    min-width: 320px;
    max-width: 640px;
    font-size: 14px;
    color: #666;
    font-family: -apple-system, Helvetica, sans-serif;
    line-height: 1.5;
    background-color: #ccc;
    height: 2000px;
}

.app {
     
    width: 100%;
    height: 45px;
}

.app ul {
     
    margin: 0;
    padding: 0;
    list-style: none;
}

a {
     
    color: #666;
    text-decoration: none;
}

img {
     
    /* 去除图片底部的空白缝隙 */
    vertical-align: middle;
}

.app ul li {
     
    float: left;
    height: 45px;
    background-color: #333333;
    text-align: center;
    line-height: 45px;
    color: #fff;
}

.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;
    /* img也是行内块元素 */
    /* 出现行内块的情况,因为图片默认和文字的基线对齐,所以要对其进行设置,使文字和图片居中对齐 */
    vertical-align: middle;
}

.app ul li:nth-child(3) {
     
    width: 57%;
}

.app ul li:nth-child(4) {
     
    width: 25%;
    background-color: #E1251B;
}

.search-wrap {
     
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 44px;
    min-width: 320px;
    max-width: 640px;
}

.search-btn::before {
     
    content: "";
    display: block;
    width: 20px;
    height: 18px;
    background: url(../images/s-btn.png);
    background-size: 20px 18px;
    /* 用magin的原因是因为是背景图片 不能居中 */
    margin: 14px 0 0 15px;
}

.search-btn {
     
    width: 40px;
    height: 44px;
    position: absolute;
    top: 0;
    left: 0;
    /* background-color: pink; */
}

.search-login {
     
    width: 40px;
    height: 44px;
    position: absolute;
    top: 0;
    right: 0;
    /* background-color: purple; */
    line-height: 44px;
    /* text-align: center; */
    color: #fff;
}

.search {
     
    position: relative;
    height: 30px;
    background-color: white;
    margin: 0 50px;
    border-radius: 15px;
    margin-top: 7px;
}

.jd-icon {
     
    width: 20px;
    height: 15px;
    position: absolute;
    top: 8px;
    left: 13px;
    background: url(../images/jd.png) no-repeat;
    background-size: 20px 15px;
}

.jd-icon::after {
     
    content: "";
    position: absolute;
    right: -20px;
    display: block;
    width: 1px;
    height: 15px;
    background-color: #ccc;
}

.sou {
     
    position: absolute;
    top: 8px;
    left: 55px;
    /* 精灵图2倍图的做法 */
    width: 18px;
    height: 15px;
    background: url(../images/jd-sprites.png) no-repeat -81px 0;
    background-size: 200px auto;
}

.slider img {
     
    /* 跟父亲一样宽 */
    width: 100%;
}


/* 品牌日 */

.brand {
     
    /* 对盒子切割没有对图片切割,用overflow: hidden;把多余的图片切割 */
    overflow: hidden;
    border-radius: 10px 10px 0 0;
}

.brand div {
     
    float: left;
    width: 33.33%;
}

.brand div img {
     
    width: 100%;
}

nav {
     
    padding-top: 5px;
}

nav a {
     
    float: left;
    width: 20%;
    text-align: center;
}

nav a img {
     
    width: 40px;
    margin: 10px 0;
}

nav a span {
     
    display: block;
}


/* news */

.news a {
     
    margin-top: 20px;
    float: left;
    /* C3盒子模型 可以把border放进去  并不影响布局也不用加减边距,内外边框 */
    box-sizing: border-box;
}

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

.news img {
     
    width: 100%;
}


/* .news a:nth-child(2),
.news a:nth-child(3) {
    width: 25%;
} */


/* 公式   从第2个往后面选*/

.news a:nth-child(n+2) {
     
    width: 25%;
}

你可能感兴趣的:(移动端开发,css3,html5)