CSS常见布局样式

1丶Flex布局自动换行均等布局(三个)

    <div class="goods-content">
      <div class="goods-list" v-if="!searchStatus">
        <div class="goods-item" v-for="(item,index) in goodsList" :key="index">
          <div class="content">
            <div class="card-top">
              <img class="img" src="../../assets/home/banner.jpg" alt="">
            </div>
            <div class="name">100元卡</div>
            <div class="price">
              <div class="sale-price">96</div>
              <div class="old-price">196</div>
            </div>
            <div class="go-buy" @click="goDetails(item.id,1)">马上抢 ></div>
          </div>
        </div>
      </div>
    </div>

<style scoped lang='scss'>
.goods-content {
  width: 100%;
  box-sizing: border-box;
  padding: 0 20px;

  .goods-list {
    display: flex;
    justify-content: start;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
    height: 200px;
    box-sizing: border-box;
    padding: 0 0.5%;

    .goods-item {
      width: 33%;
      margin-bottom: 30px;

      &:nth-child(3n) {
        .content {
          float: right;
        }
      }

      &:nth-child(3n-1) {
        .content {
          margin: 0 auto;
        }
      }

      .content {
        width: 90%;
        padding-bottom: 1px;
        background: #ffffff;
        border-radius: 16px;
        overflow: hidden;

        .card-top {
          width: 100%;
          height: 180px;
          background-color: #FFEDE3;
          overflow: hidden;

          .img {
            width: 80%;
            height: 100px;
            margin: 46px auto;
          }
        }

        .name {
          width: 100%;
          box-sizing: border-box;
          padding: 0 14px;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 2;
          font-size: 26px;
          font-weight: 400;
          text-align: left;
          color: #1a1a1a;
        }

        .price {
          display: flex;
          justify-content: start;
          align-items: center;
          margin-top: 10px;

          .sale-price {
            margin-left: 14px;
            font-size: 22px;
            font-weight: 500;
            color: #cb1c37;
          }

          .old-price {
            margin-left: 11px;
            font-size: 20px;
            font-weight: 400;
            text-decoration: line-through;
          }
        }

        .go-buy {
          width: 180px;
          height: 38px;
          margin: 14px auto 16px;
          background: #cb1c37;
          border-radius: 8px;
          font-size: 20px;
          font-weight: 400;
          text-align: center;
          color: #ffffff;
        }
      }
    }
  }
}
</style>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值