小米商城 商品楼层 用弹性盒子实现相关代码

时间有限,代码注释不多,有不清楚的地方请私信,我会第一时间回复!!!!!!!!

运行后网页图片:

html 代码:

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>小米商品楼层</title>
    <link rel="stylesheet" href="./css/common.css">
    <link rel="stylesheet" href="./css/xiaomi.css">
</head>
<body>
    <div class="container">
        <div class="box">
            <div class="left">
                <a href="#">
                    <div class="img1">
                        <img src="./imgs/xiaimishouji.webp" alt="">
                    </div>
                </a>
            </div>
            <div class="right">
                <ul>
                    <li>
                        <a href="#">
                            <div class="img">
                                <img src="./imgs/202403201526_60b548a0614d956b2d3667a63d513539.webp" alt="">
                            </div>
                            <h2>Xiaomi Civi 4 Pro</h2>
                            <p class="p1">徕卡光学Summilux镜头 | 5000万徕卡...</p>
                            <p class="p2">2999元起</p>
                        </a>
                    </li>
                    <li>
                        <a href="#">
                            <div class="img">
                                <img src="./imgs/202403201526_60b548a0614d956b2d3667a63d513539.webp" alt="">
                            </div>
                            <h2>Xiaomi Civi 4 Pro</h2>
                            <p class="p1">徕卡光学Summilux镜头 | 5000万徕卡...</p>
                            <p class="p2">2999元起</p>
                        </a>
                    </li>
                    <li>
                        <a href="#">
                            <div class="img">
                                <img src="./imgs/202403201526_60b548a0614d956b2d3667a63d513539.webp" alt="">
                            </div>
                            <h2>Xiaomi Civi 4 Pro</h2>
                            <p class="p1">徕卡光学Summilux镜头 | 5000万徕卡...</p>
                            <p class="p2">2999元起</p>
                        </a>
                    </li>
                    <li>
                        <a href="#">
                            <div class="img">
                                <img src="./imgs/202403201526_60b548a0614d956b2d3667a63d513539.webp" alt="">
                            </div>
                            <h2>Xiaomi Civi 4 Pro</h2>
                            <p class="p1">徕卡光学Summilux镜头 | 5000万徕卡...</p>
                            <p class="p2">2999元起</p>
                        </a>
                    </li>
                    <li>
                        <a href="#">
                            <div class="img">
                                <img src="./imgs/202403201526_60b548a0614d956b2d3667a63d513539.webp" alt="">
                            </div>
                            <h2>Xiaomi Civi 4 Pro</h2>
                            <p class="p1">徕卡光学Summilux镜头 | 5000万徕卡...</p>
                            <p class="p2">2999元起</p>
                        </a>
                    </li>
                    <li>
                        <a href="#">
                            <div class="img">
                                <img src="./imgs/202403201526_60b548a0614d956b2d3667a63d513539.webp" alt="">
                            </div>
                            <h2>Xiaomi Civi 4 Pro</h2>
                            <p class="p1">徕卡光学Summilux镜头 | 5000万徕卡...</p>
                            <p class="p2">2999元起</p>
                        </a>
                    </li>
                    <li>
                        <a href="#">
                            <div class="img">
                                <img src="./imgs/202403201526_60b548a0614d956b2d3667a63d513539.webp" alt="">
                            </div>
                            <h2>Xiaomi Civi 4 Pro</h2>
                            <p class="p1">徕卡光学Summilux镜头 | 5000万徕卡...</p>
                            <p class="p2">2999元起</p>
                        </a>
                    </li>
                    <li>
                        <a href="#">
                            <div class="img">
                                <img src="./imgs/202403201526_60b548a0614d956b2d3667a63d513539.webp" alt="">
                            </div>
                            <h2>Xiaomi Civi 4 Pro</h2>
                            <p class="p1">徕卡光学Summilux镜头 | 5000万徕卡...</p>
                            <p class="p2">2999元起</p>
                        </a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</body>
</html>

css 代码:

xiaomi.css

body {
    background-color: #f5f5f5;
}

/* .container {
    background-color: #fff;
} */

.container .box {
    height: 614px;

    display: flex;
    justify-content: space-between;
}

.container .left {
    width: 234px;
    height: 614px;
    transition: all 0.5s;

}

.img {
    width: 234px;
    height: 614px;
}

img {
    width: 100%;
    height: 100%;
}

.right {
    width: 978px;
    height: 614px;


}

.right ul li {
    width: 234px;
    height: 300px;
    background-color: #fff;
    margin-bottom: 14px;
    transition: all 0.5s;


    /* display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px 0;
    align-items: center; */


}

h2 {
    font-size: 14px;
    color: #333;
    font-weight: 400;
    margin-top: 5px;
    /* margin-bottom: 5px; */
}


.img {
    width: 160px;
    height: 160px;
}

.img img {
    margin-top: -15px;
    width: 100%;
    height: 100%;
}

.p1 {
    font-size: 12px;
    color: #b0b0b0;
    margin-bottom: 15px;
}

.p2 {
    font-size: 14px;
    color: #ff6700;
}

.right ul li a {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px 0;
    align-items: center;

    height: 100%;


}

.right ul {
    height: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-content: space-between;

}

li:hover {

    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
    margin-top: -1px;

}
.left:hover {

    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
    margin-top: -1px;

}

common.css

blockquote, body, button, dd, dl, dt, fieldset, form, h1, h2, h3, h4, h5, h6, hr, input, legend, li, ol, p, pre, td, textarea, th, ul{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

li {
    list-style-type: none;
}

a {
    text-decoration: none;
}

.container {
    width: 1226px;
    margin: 0 auto;

}

相关引用图片我放在下面,也可去小米官网自行下载

  • 10
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值