[英]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.