前端移动Web第一天:流式布局-京东首页案例


<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    
    <link rel="stylesheet" href="CSS/normalize.css">
    
    <link rel="stylesheet" href="CSS/index.css">
    <title>京东首页title>

head>
<body>
    
    <header class="app">
        <ul>
            <li>
                <img src="images/close.png" alt="">
            li>
            <li>
                <img src="images/logo.png" alt="">
            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="sou">div>
        div>
        <div class="search-login">登录div>
    div>

    
    <div class="main-content">div>
    
    <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> 
        <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/nav3.webp" alt="">
            <span>京东超市span>
        a>
        <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/nav3.webp" alt="">
            <span>京东超市span>
        a>
        <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/nav3.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>
body>
html>
body {
     
    width: 100%;
    min-width: 320px;
    max-width: 640px;
    margin: 0 auto;
    font-size: 14px;
    color: #666;
    /* 苹果字体: */
    font-family: -apple-system, Arial, Helvetica, sans-serif;
    background-color: #ccc;
}
a {
     
    color: #666;
    text-decoration: none;
}
/* 图片去除空白缝隙: */
img {
     
    vertical-align: top;
}

/* 头部:  */
ul {
     
    margin: 0;
    padding: 0;
    list-style: none;
}
.app {
     
    height: 45px;
}
.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;
    vertical-align: middle;
}
.app ul li:nth-child(3) {
     
    width: 57%;
}
.app ul li:nth-child(4) {
     
    width: 25%;
    background-color: #F63515;
}


/* 搜索框: */
.search-wrap {
     
    position: fixed;
    width: 100%;
    height: 44px;
    /* 解决外边距合并问题: */
    overflow: hidden;
    min-width: 320px;
    max-width: 640px;
}
.search-btn {
     
    position: absolute;
    left: 0;
    top: 0;
    width: 40px;
    height: 44px;
}
.search-btn::before {
     
    content: "";
    /* 因为是行内元素,所以必须加: */
    display: block;
    width: 20px;
    height: 18px;
    background: url(../images/s-btn.png) no-repeat;
    background-size: 20px 18px;
    margin: 14px 0 0 15px;
}
.search {
     
    position: relative;
    margin: 0 50px;
    height: 30px;
    background-color: #fff;
    border-radius: 20px;
    margin-top: 7px;
}
.search-login {
     
    position: absolute;
    right: 0;
    top: 0;
    width: 40px;
    height: 44px;
    color: #fff;
    line-height: 44px;
}
.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: "";
    display: block;
    width: 1px;
    height: 15px;
    background-color: #ccc;
    position: absolute;
    right: -8px;
    top: 0;
}
.sou {
     
    position: absolute;
    top: 8px;
    left: 50px;
    width: 18px;
    height: 15px;
    background: url(../images/jd-sprites@2x.png) no-repeat -81px 0;
    background-size: 200px auto;
}


/* 滑动图: */
.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 {
     
    overflow: hidden;
    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 {
     
    overflow: hidden;
    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(2),
.news a:nth-child(3) {
     
    width: 25%;
    border-left: 1px solid #ccc;
}

前端移动Web第一天:流式布局-京东首页案例_第1张图片

第二种:


<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>京东购物title>
    <link rel="icon" href="favicon.ico" />
    <link rel="stylesheet" href="CSS/index.css">
head>
<body>
    
    <header class="header">
        <a href="#"><img src="images/close.png" alt="">a>
        <a href="#"><img src="images/logo.png" alt="">a>
        <a href="#">打开京东APP,购物更轻松a>
        <a href="#">立即打开a>
    header>
    
    <div class="search">
        <a href="#" class="search-l">
            <img src="images/s-btn.png" alt="">
        a>
        <div class="search-c">div>
        <a href="#" class="search-r">登录a>
    div>
    
    <div class="banner">
        <a href="#">
            <img src="upload/banner.dpg" alt="">
        a>
    div>
    
    <div class="brand">
        <a href="#"><img src="upload/pic11.dpg" alt="">a>
        <a href="#"><img src="upload/pic22.dpg" alt="">a>
        <a href="#"><img src="upload/pic33.dpg" alt="">a>
    div>
    
    <div class="nav">
        <a href="#"><img src="upload/nav1.webp" alt="">京东超市a>
        <a href="#"><img src="upload/nav1.webp" alt="">京东超市a>
        <a href="#"><img src="upload/nav1.webp" alt="">京东超市a>
        <a href="#"><img src="upload/nav1.webp" alt="">京东超市a>
        <a href="#"><img src="upload/nav1.webp" alt="">京东超市a>
        <a href="#"><img src="upload/nav1.webp" alt="">京东超市a>
        <a href="#"><img src="upload/nav1.webp" alt="">京东超市a>
        <a href="#"><img src="upload/nav1.webp" alt="">京东超市a>
        <a href="#"><img src="upload/nav1.webp" alt="">京东超市a>
        <a href="#"><img src="upload/nav1.webp" alt="">京东超市a>
    div>
    
    <div class="sale">
        <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 class="footer">
        <a href="#"><img src="images/index-icon.png" alt="">a>
        <a href="#"><img src="images/sort-icon.png" alt="">a>
        <a href="#"><img src="images/618-icon.png" alt="">a>
        <a href="#"><img src="images/cart-icon.png" alt="">a>
        <a href="#"><img src="images/center-icon.png" alt="">a>
    div>
body>
html>
*{
     
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}
a{
     
    text-decoration: none;
    color: #666;
}

/* 公共样式初始化 */
body{
     
    min-width: 320px;
    max-width: 640px;
    margin: 0 auto;
}


/* 头部区域 */
.header{
     
    overflow: hidden;
    height: 44px;
    background-color: black;
}
.header a{
     
    float: left;
    text-align: center;
    line-height: 44px;
    color: #fff;
    font-size: 16px;
}
.header a:nth-child(1){
     
    width: 8%;
}
.header a:nth-child(1) img{
     
    width: 10px;
    height: 10px;
}
.header a:nth-child(2){
     
    width: 10%;
}
.header a:nth-child(2) img{
     
    width: 30px;
    height: 30px;
    vertical-align: middle;
}
.header a:nth-child(3){
     
    width: 57%;
}
.header a:nth-child(4){
     
    width: 25%;
    background-color: red;
}


/* 搜索框区域 */
.search{
     
    min-width: 320px;
    max-width: 640px;
    width: 100%;
    height: 45px;
    background-color: orange;
    position: fixed;
}
.search a{
     
    width: 40px;
    height: 45px;
    background-color: pink;
    position: absolute;
    top: 0;
    line-height: 45px;
    text-align: center;
    color: #fff;
}
.search .search-l{
     
    left: 0;
}
.search .search-l img{
     
    width: 20px;
    height: 16px;
}
.search .search-c{
     
    height: 30px;
    background-color: #fff;
    margin: 0 45px;
    border-radius: 15px;
    margin-top: 7px;
}
.search .search-r{
     
    right: 0;
}


/* 大banner区域 */
.banner a img{
     
    width: 100%;
}


/* 小banner区域 */
.brand{
     
    width: 100%;
    overflow: hidden;
}
.brand a{
     
    width: 33.33%;
    float: left;
}
.brand a img{
     
    width: 100%;
}


/* 导航栏区域 */
.nav{
     
    overflow: hidden;
    background-color: #ccc;
    padding-top: 10px;
    margin-bottom: 10px;
}
.nav a{
     
    float: left;
    width: 20%;
    text-align: center;
    margin-bottom: 10px;
}
.nav a img{
     
    display: block;
    width: 40px;
    height: 40px;
    margin: 5px auto;
}


/* 每日抽奖区域 */
.sale{
     
    width: 100%;
    overflow: hidden;
}
.sale a{
     
    float: left;
    width: 25%;
}
.sale a:nth-child(1){
     
    width: 50%;
}
.sale a:nth-child(2){
     
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
}
.sale a img{
     
    width: 100%;
}


/* 底部导航栏 */
.footer{
     
    overflow: hidden;
    min-width: 320px;
    max-width: 640px;
    width: 100%;
    position: fixed;
    height: 50px;
    background-color: orange;
    bottom: 0px;
}
.footer a{
     
    float: left;
    width: 20%;
    text-align: center;
    padding-top: 5px;
}
.footer a img{
     
    width: 57px;
    height: 44px;
}

前端移动Web第一天:流式布局-京东首页案例_第2张图片

你可能感兴趣的:(一:移动WEB学习(看视频),css,html)