简体   繁体   English

如何限制 flexbox 中显示项目的数量?

[英]How to limit number of displayed items in flexbox?

I want to have only 6 items in one row, i don't want another 6 in next row.我只想在一行中有 6 个项目,我不想在下一行再有 6 个。 So the plan is to show 6 items in one row and button see more or something that will take user to another page where all items will be displayed.因此,计划是在一行中显示 6 个项目,并通过按钮see more或将用户带到另一个页面,其中将显示所有项目。 This is my code:这是我的代码:

   <div class="flex-div">            
        <c:forEach var="book" items="${bookList}">
            <div><img src="Images/book${book.imageId}.png" alt="book"
                  height="190px" width="150px"/></div>
            <div id="book-title">${book.title}</div>
            <div id="book-price">${book.price}$</div> 
        </c:forEach>           
    </div>

and css:和 css:

.flex-div{
padding: 20px;
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;

} }

What should i do?我应该怎么办?

flexbox will not stop at a certain number by itself, this problem needs a solution by your other language, it seems you are using JSP which im not familiar with, but you have to provide the flexbox only 6 items, and then do and (if-else) after flexbox to check if your items count is above 6, then you show "show more" other than that, css can't do logic like that. flexbox 本身不会停在某个数字上,这个问题需要用你的其他语言来解决,看来你正在使用我不熟悉的 JSP,但是你必须提供 Z7F3D565C67F89F89F27A301D03D 项目(只有 7 和 541 和 9F27A331D03D) -else)在 flexbox 检查您的项目数是否高于 6 之后,然后显示“显示更多”,除此之外,css 不能执行这样的逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 每个显示数量限制 - Limit number of displayed items with th:each 如何限制回收站视图中的项目数量? - How to limit number of items in Recycler View? 如何限制使用Scala显示的字符串中的字符数 - How to limit the number of characters in a string displayed using Scala 如何限制单页 DynamoDB 结果中返回的项目数 - How to limit the number of items returned in a single page of DynamoDB result 如何限制可以添加到列表中列表的项目数 - How to limit the number of items that can be added to a list in a list 如何循环和限制每次在 Observable 中获取的项目数 - How to loop and limit the number of items fetched each time in an Observable 如何限制ROME Fetcher中已下载(已解析)条目(项目)的数量 - How to limit number of downloaded (parsed) entries (items) in ROME Fetcher jsf中可以显示的行数限制 - number of rows limit that can be displayed in jsf 计算RecyclerView显示的项目数并将其放置在TextView中 - Calculate the number of items displayed by RecyclerView and place in a TextView 如何限制在多个活动中使用的 Android 自定义 ListView 中显示的字符数? - How To Limit The Number of Characters displayed In Android Custom ListView which is used in Multiple activities?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM