我可以仅设置“ n n&quot”在弹性容器中可见的行数?

发布于 2025-02-06 15:03:48 字数 244 浏览 3 评论 0原文

我有一个带有以下CSS的容器:

.container {
   display: flex;
   flex-direction: row;
   flex-wrap: wrap;
}

是否有任何方法可以将其限制为仅显示n行,而其余行未显示?我想避免设置固定高度,因为容器中的元素可能具有不同的高度(这可能导致不同的行是不同的高度)。

I have a container with the following CSS:

.container {
   display: flex;
   flex-direction: row;
   flex-wrap: wrap;
}

Is there any way to limit it to only displaying N rows, with the remaining rows not showing? I'd like to avoid setting a fixed height, as the elements in the container have potentially differing heights (which might lead to different rows being different heights).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乱了心跳 2025-02-13 15:03:48

那是你的意思吗?请问,如果我错了。

.container {
   display: flex;
   flex-direction: row;
   flex-wrap: wrap;
}

.child{
 display: none;
}

.child:nth-child(2){
 display : block;
}
<div class ="container">
  <div class="child">I am a child</div>
  <div class="child">I am a child too</div>
</div>

Is that what you meant?. excuse me if I got it wrong.

.container {
   display: flex;
   flex-direction: row;
   flex-wrap: wrap;
}

.child{
 display: none;
}

.child:nth-child(2){
 display : block;
}
<div class ="container">
  <div class="child">I am a child</div>
  <div class="child">I am a child too</div>
</div>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文