响应式布局(多媒体查询)仿苹果官网部分实例

 

 

html代码部分:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./node_modules/_@fortawesome_fontawesome-free@6.0.0@@fortawesome/fontawesome-free/css/all.css">
    <link rel="stylesheet" href="./index.css">
</head>
<body>
    <!--移动端布局-->
    <div id="top">
        <div>
            <ul>
                <li></li>
                <li></li>
               
            </ul>
        </div>
        <div>
            <i class="pingguo fab fa-apple fa-xs"></i>
        </div>
        <div>
            <i class="fas fa-shopping-bag fa-xs"></i>
            
        </div>
    </div>
    <!--pc端布局-->
    <div id="mobile">
        <ul>
            <li>
                <i class="pingguo fab fa-apple fa-xs"></i>
            </li>
            <li>商店</li>
            <li>Mac</li>
            <li>iPad</li>
            <li>Watch</li>
            <li>AirPods</li>
            <li>家居</li>
            <li>Apple独家</li>
            <li>配件</li>
            <li>技术支持</li>
            <li>
                <i class="fas fa-search fa-xs"></i>
            </li>
            <li> 
                <i class="fas fa-shopping-bag fa-xs"></i>
            </li>
        </ul>
    </div>

    <div id="message">
        <div><a href="#">在线选购</a>
        ,享受免费送货、Specialist 专家支持、免息分期等服务</div>
    </div>
    <div id="ad">
       <img/>
    </div>
</body>
</html>
<!--
    img src="https://empic.dfcfw.com/863614397355180033/w368h744/art"/>
    https://pics7.baidu.com/feed/960a304e251f95ca6092129087137b34670952bb.jpeg?token=a4d104d06323329964ff727875119db2
-->

 

less文件:
*{
    padding: 0;
    margin: 0;
    a{
        text-decoration: none;
    }
    ul{
        list-style-type:none;
    }
}
#mobile{
    position: sticky;
    top: 0;
    background-color: black;
    padding:0 18px;
    ul{
        width: 100%;
        display: flex;
        justify-content: space-around;
        align-items: center;
        li:nth-child(1),
        li:nth-child(11),
        li:nth-child(12){
            line-height: 48px;
            font-size: 28px;
            i{
                color:white;
                width: 33px;
                display: block;
                height: 48px;
                line-height: 48px;
                
            }
        }
        li{
           color:white;
           font-size: 12px;
        }
    }
  
}
#top{
    position: sticky;
    top: 0;
    background-color: black;
    padding:0 18px;
    display: flex;

    justify-content: space-between;
    align-items: center;
    div{
        height: 48px;
        line-height: 48px;
    }
    div:nth-child(1){
        width:48px;
        ul{
           
            display: flex;
            flex-direction: column;
            height: 48px;
            justify-content: center;
            list-style-type: none;
            li:nth-child(1){
                border-top: 1px solid white;
            }
            li{
               
                line-height: 48px;
                width: 15px;
                border-bottom: 1px solid white;
                padding: 3px;
                margin-bottom: 1px;
            }
        }
    }
    div:nth-child(2), div:nth-child(3){
        line-height: 48px;
        font-size: 28px;
        i{
            color:white;
            width: 33px;
            display: block;
            height: 48px;
            line-height: 48px;
            
        }
    }
   
}

#message{
    display: flex;
    align-items: center;
    width: 100%;
    background-color: #f5f5f7;
    font-size: 10px;
    height: 61.16px;
    text-align: center;
    color: #8b8b8d;
    div{
        margin: auto;
        padding:0 24px;
    }

}
@media (max-width:303px){
    #message{
        width: 303px;
    }
}
@media (max-width:734px){
    #top{
        display: flex;
    }
    #mobile{
        display: none;
    }
    #ad{
        img{
            width: 100%;
            content: url('https://empic.dfcfw.com/863614397355180033/w368h744/art');  
            background-size:cover;
        }  
    }
    
}
@media (max-width:1400px) and (min-width:735px){
    #top{
        display: none;
    }
    #mobile{
        display: flex;
    }
    #ad{
        img{
            width:735px;
            display: block;
            margin: auto;
            content: url('https://mms1.baidu.com/it/u=1127784663,1190904074&fm=253&app=120&f=JPEG&fmt=auto&q=75?w=660&h=470');  
            background-size:cover;
        }  
    }
    
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Gjanuary

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值