利用弹性盒实现移动端商品列表

 

 

HTML部分:

  <div class="wrap">
        <ul class="cosmeticnav">
            <li><a href="#cosmeticlist">热门推荐</a></li>
            <li><a href="#cosmeticlist">发现好货</a></li>
            <li><a href="#cosmeticlist">只看专场</a></li>
            <li><a href="#cosmeticlist">只看商品</a></li>
        </ul>

        <div class="cosmeticlist" id = "cosmeticlist">
            <a class="cosmetic" href="./html/detail.html">
                <!-- left -->
                <div class="cosmeticimg">
                    <img src="./images/index/shop_4.jpg" alt="cosmetic" class = "first">
                </div>
                <!-- right -->
                <div class="cosmeticdesc">
                    <h3>雅诗兰黛胶原霜 修护抗皱</h3>
                    <p class="price"><b>¥</b>123.00</p>
                    <p class="sell">已售800件</p>
                    <button>立即抢购</button>
                </div>
            </a>
            <a class="cosmetic" href="./html/detail.html">
                <!-- left -->
                <div class="cosmeticimg">
                    <img src="./images/index/shop_6.jpg" alt="cosmetic" class = "second">
                </div>
                <!-- right -->
                <div class="cosmeticdesc">
                    <h3>雅丽 滋润面膜乳霜 护肤</h3>
                    <p class="price"><b>¥</b>332.00</p>
                    <p class="sell">已售900件</p>
                    <button>立即抢购</button>
                </div>
            </a>
            <a class="cosmetic" href="./html/detail.html">
                <!-- left -->
                <div class="cosmeticimg">
                    <img src="./images/index/shopCart.jpg" alt="cosmetic" class="first">
                </div>
                <!-- right -->
                <div class="cosmeticdesc">
                    <h3>透蜜水漾 美肤素颜霜</h3>
                    <p class="price"><b>¥</b>88.90</p>
                    <p class="sell">已售1000件</p>
                    <button>立即抢购</button>
                </div>
            </a>
        </div>
    </div>

CSS部分

.wrap .cosmeticnav {
  margin: 0.2rem 0;
  width: 100%;
  height: 0.7rem;
  display: flex;
  justify-content: space-between;
  box-sizing: border-box;
}
.wrap .cosmeticnav li {
  width: 25%;
  height: 100%;
  line-height: 0.8rem;
  border: 1px solid #ebebeb;
  text-align: center;
}
.wrap .cosmeticnav li:hover {
  background-color: #f26b11;
}
.wrap .cosmeticnav li:hover a {
  color: #ffffff;
}
.wrap .cosmeticnav li a {
  color: #3c3c3c;
  font: 0.3rem/1 "微软雅黑";
}
.wrap .cosmeticnav li:nth-last-of-type(-n+3) {
  border-left-style: none;
}
.wrap .cosmeticlist .cosmetic {
  width: 100%;
  height: 3rem;
  box-shadow: 0 0 0.2rem #eeeeee;
  border: 1px solid #ebebeb;
  display: flex;
  margin-bottom: 0.34rem;
}
.wrap .cosmeticlist .cosmetic:hover .cosmeticdesc h3 {
  color: #ef6b16;
  text-decoration: underline;
}
.wrap .cosmeticlist .cosmetic .cosmeticimg {
  width: 50%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-around;
}
.wrap .cosmeticlist .cosmetic .cosmeticimg .first {
  width: 2.16rem;
  height: 2.2rem;
}
.wrap .cosmeticlist .cosmetic .cosmeticimg .second {
  width: 2.18rem;
  height: 2.98rem;
}
.wrap .cosmeticlist .cosmetic .cosmeticdesc {
  width: 50%;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.wrap .cosmeticlist .cosmetic .cosmeticdesc h3 {
  font: 0.3rem/1 "微软雅黑";
  color: #2e2e2e;
  margin-top: 0.42rem;
}
.wrap .cosmeticlist .cosmetic .cosmeticdesc .price {
  font-size: 0.28rem;
  color: #db3c39;
  margin-top: 0.2rem;
}
.wrap .cosmeticlist .cosmetic .cosmeticdesc .price b {
  font-size: 0.21rem;
}
.wrap .cosmeticlist .cosmetic .cosmeticdesc .sell {
  margin-top: 0.3rem;
  font-size: 0.2rem;
  color: #bebebe;
}
.wrap .cosmeticlist .cosmetic .cosmeticdesc button {
  margin-top: 0.32rem;
  width: 1.64rem;
  height: 0.52rem;
  border-radius: 0.05rem;
  background-color: #f26b11;
  color: #f1f1f1;
  font-size: 0.23rem;
  cursor: pointer;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值