[英]css flex-box wrap but avoid region
I have a div that uses flex and wraps the items... 我有一个使用flex并包装物品的div ...
#container
{
display: flex;
flex-wrap: wrap;
}
The items wrap to the next row when they reach the end of the container. 当这些项目到达容器的末端时,它们将包装到下一行。 I need a region which the items will also wrap around.
我需要一个区域,物品也将环绕。 Here is an example of what I want...
这是我想要的一个例子...
The items(grey) wrap the the next row when they reach the region(red). 物品(灰色)到达区域(红色)时会包裹下一行。
I am wondering if this possible to do using flex-box. 我想知道是否可以使用flex-box。
Thank you. 谢谢。
Check out this proof-of-concept which uses CSS Grid Layout
. 查看使用
CSS Grid Layout
的概念验证。 You can skip a region in the grid by using a pseudo element that is empty and is explicitly placed to create the effect that wrapped elements flow around it. 您可以通过使用为空的伪元素来跳过 网格中的区域,该伪元素被明确放置以创建包裹元素在其周围流动的效果。
See demo below: 请参见下面的演示:
.grid { display: grid; grid-gap: 10px; grid-template-columns: repeat(6, [col-start] 1fr); } .grid>* { background-color: green; height: 60px; display: flex; justify-content: center; align-items: center; } .grid:after { content: ''; grid-row: 1; /* row 1 */ grid-column: 4/7; /* skip columns 4 to 6 */ border: 1px dashed #ddd; }
<div class="grid"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> <div>6</div> <div>7</div> <div>8</div> <div>9</div> <div>10</div> <div>11</div> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.