浅模仿小米商城布局(有微调)

这篇文章详细描述了使用CSS进行网页布局和样式的编写,包括使用`class`选择器设置div元素的高度、宽度、颜色、浮动、对齐方式以及鼠标悬停效果,如`.h111`的flex布局和`.s111a`的hover样式。
摘要由CSDN通过智能技术生成

 CSS文件

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

div[class^="h"]{
    height: 40px;
}
div[class^="s"]{
    height: 100px;
}
.h1{
    width: 1528px;
    background-color: green;
}
.h11{
    background-color:rgb(8, 220, 8);
}
.h111{
    width: 683px;
    background-color: yellow;
    float: left;
    display: flex;
    justify-content: space-around;

}
.h111 a{
    display: block;
    width: 56px;height: 40px;
    background-color: brown;
}
.h112{
    width: 256px;
    background-color:yellow;
    float: right;
}
.h112 a{
    display: inline-block;
    width: 63px;
    height: 40px;
    margin-right: 1px;
    background-color: deeppink}
.s1{
    width: 1528px;
    background-color: plum;
}
.s11{
    width: 1288px;
    background-color: blue;
    display: flex;
    align-items: center;
}
.mi{
    width: 56px;
    height: 56px;
    background-color: orange;
  }
.s111{
    width: 860px;
    background-color: greenyellow;
    padding: 12px 34px 0 142px;
    display: flex;
    justify-content: space-evenly;
}
.s111 a{
    display: block;
    height: 88px;
    width: 74.5px;
    background-color: olive;
}
.s111 a:hover{
    background-color: #fff;
}
.mm{
    width: 372px;
    height: 50px;
    background-color: rgb(108, 46, 222);
    display: flex;
}
.mm1,.mm2{
    margin: 0 10px;
    height: 50px;
    background-color: aqua;
}
.mm2{
    width: 272px;
}
.mm1{
    width: 60px;
}
.t1,ul{
    height: 460px;
}
.t1{
    background-color: brown;
    position: relative;
}
ul{
    width: 234px;
    background-color: rgb(254, 11, 177);
    float: left;
    padding:20px 0px;
}
 ul>a{
     display: block;
     height: 42px;
     width: 234px;
     background-color: rgb(133, 199, 253);
 }
 ul a:nth-of-type(2n){
     background-color: rgb(62, 62, 255);
 }
 ul a:hover{
    background-color: #fff;
}
.t11,.t12{
    width: 41px;
    height: 69px;
    background-color: yellow;
    position: absolute;
    top:230px;
    margin-top:-34.5px
}
.t11{
    left: 234px;
}
.t12{
   right: 0;
}
.t3{
    position: absolute;
    width: 400px;
    height: 18px;
    background-color: rgb(252, 236, 236);
    right: 30px;
    bottom: 20px;
}
.t33{
    width: 20px;
    height: 10px;
    float: right;
    background-color: rgb(80, 158, 6);
    margin: 5px 0;
}
.t33 a{
    display: block;
    margin: 0 auto;
    width: 10px;
    height: 10px;
    background-color: yellow;
    border-radius: 50%;
}
.t33 a:hover{
    background-color: black;
}
.f1,.f2{
    height: 170px;
}
.f1{
    background-color:purple;
    margin: 14px auto;
    display: flex;
    justify-content: space-between; 
}
.f2{
    width: 296px;
    background-color: rgb(179, 254, 254,0.5);
   
}
.f2:first-child{
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
}
.f22
{
    width: 98px;
    height: 83px;
    background-color: pink;
}

.b1{
    height: 58px;
    background-color: red;
    margin-top: 25px;
    margin-left: auto;margin-right: auto;

}

.x1{
    height: 340px;
    background-color: rgb(8, 157, 215);
    display: flex;
    justify-content: space-between;
}
.x2{
 height: 339px;
 width: 234px;
 margin-bottom: 0;
 background-color: rgb(254, 254, 5,0.5);
}
.x1,.t1,.s1,.s11,.h1,.h11{
    margin: 0 auto;
}
.x1,.b1,.f1,.t1,.h11{
    width: 1226px;
}

html

<!DOCTYPE html><head>
    <meta charset="UTF-8">
    <title>Document</title>
  <link rel="stylesheet" href="./小米.css">
</head>

<body>
    <!-- 第1块 -->
  <div class="h1">
    <div class="h11">
         <div class="h111">
             <a href=""></a><a href=""></a>
             <a href=""></a><a href=""></a>
             <a href=""></a><a href=""></a>
             <a href=""></a><a href=""></a>
             <a href=""></a><a href=""></a>
             <a href=""></a><a href=""></a>
         </div>
         <div class="h112">
             <a href=""></a><a href=""></a><a href=""></a><a href=""></a>
         </div>
    </div>
</div>

    <!-- 第2块 -->
    <div class="s1">
        <div class="s11">
            <div class="mi"></div>
            <div class="s111"> 
                <a href=""></a><a href=""></a>
                <a href=""></a><a href=""></a>
                <a href=""></a><a href=""></a>
                <a href=""></a><a href=""></a>
                <a href=""></a>
            </div>
            <div class="mm">
                <div class="mm2"></div>
                <div class="mm1"></div>
            </div>
        </div>
    </div>

    <!-- 第3块 -->
    <div class="t1">
        <ul>
          <a href=""></a>
          <a href=""></a>
           <a href=""></a>
           <a href=""></a>
           <a href=""></a>
           <a href=""></a>
           <a href=""></a>
           <a href=""></a>
           <a href=""></a>
           <a href=""></a>
        </ul>
        <a href="" class="t11"></a>
        <a href="" class="t12"></a>
        <div class="t3">
            <div class="t33"><a href=""></a></div>
            <div class="t33"><a href=""></a></div>
            <div class="t33"><a href=""></a></div>
            <div class="t33"><a href=""></a></div>
        </div>
    </div>

    <!-- 第4块 -->
    <div class="f1">
        <div class="f2">
            <div class="f22"></div>
            <div class="f22"></div>
            <div class="f22"></div>

            <div class="f22"></div>
            <div class="f22"></div>
            <div class="f22"></div>
        </div>
        <div class="f2"></div>
        <div class="f2"></div>
        <div class="f2"></div>
    </div>
     <!-- 第5块 -->
    <div class="b1">
    </div>
 <!-- 第6块 -->
    <div class="x1">
        <div class="x2"></div>
        <div class="x2"></div>
        <div class="x2"></div>
        <div class="x2"></div>
        <div class="x2"></div>
    </div>

</body>

</html>

我自己的作业有点写复杂了,因为写起来有点刹不住车,作业而已佳人们 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值