您好,我使用map函数和flex-Wrap:WRAP in CSS来显示卡片列表,如下所示 list of cards

有没有可能使第一张牌比其他牌大3倍,这样看起来像list of cards张,有什么css属性可以帮助我解决这个问题?或者,我应该更改html并为这张卡创建一个外部组件吗?

这是此区块的html

<div className={styles.second_part}>
        {
            news.filter(cat => cat.category === "Category").slice(0,8).map((i)=>(
                <div className={styles.normal_card}>
                    <div className={styles.normal_card_img}>
                        <Link href={'/news/'+i._id}>
                            <img src={i?.image} alt=""/>
                        </Link>
                    </div>
                    <div className={styles.normal_card_desc}>
                        <Link href={'/news/'+i._id}>
                            <h2>{i.title}</h2>
                            <span>{i.description?.length > 150 ? `${i.description?.substring(0, 150)}...` : i.description}</span>
                        </Link>
                    </div>
                </div>
            ))
        }
        </div>

和css

.second_part{
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  .normal_card {

    width: 24%;
    justify-content: center;
    margin-bottom: 25px;
    border-bottom: 1px solid #EDEDED;

    .normal_card_img {
      img {
        width: 100%;
        object-fit: cover;
        height: 300px;
      }
    }

    .normal_card_desc {
      text-align: justify;
      display: flex;
      flex-direction: column;
      margin-bottom: 10px;

      h2 {
        font-size: 16px;
        margin-bottom: 15px;

        &:hover {
          color: #ff4f00;
        }
      }

      span {
        margin-top: 15px;
      }
    }

    hr {

    }
  }
}

推荐答案

您可以使用css Select 器:first-of-type:

.card:first-of-type{
   // styles here
}

Html相关问答推荐

Flexbox嵌套div溢出

如何使div按钮链接到另一个网页

如何防止可见的滑动抽屉,同时转移HTML方向?

为什么前端框架可以创建自定义属性,而我却被期望在挖掘之前添加数据

使用响应迅速的网格系统,将两列保持在同一行,同时允许更多列用于更大的屏幕

在WooCommerce单一产品页面上使产品图片库粘滞(固定)

如何更改Django中的默认按钮?

如何将功能附加到嵌入式药剂中的按钮?

HTML中的ARIA标签:在元素内部还是外部?(&Q;

Chrome浏览器错误:上的主题验证判断https://pagead2.googlesyndication.com/失败

如何使背景图像在面包屑中相互重叠

添加带有悬停动画的喜欢图标

当多个a元素用作目标时的:target伪类

如何保持块扩展以填充视口?

即使必填字段为空,HTML 表单也已成功提交

如何用js和CSS在两点之间画一条线

在HTML请求中添加源URL

更改标签标签的大小

透明渐变凹矩形

无法使用 flexbox 裁剪图像