规范中有一部分听起来是这样的……在“flex layout algorithm”和“main sizing”部分:
Otherwise, starting from the first uncollected item, collect
consecutive items one by one until the first time that the next
collected item would not fit into the flex container’s inner main
size, or until a forced break is encountered. If the very first
uncollected item wouldn’t fit, collect just it into the line. A break
is forced wherever the CSS2.1 page-break-before/page-break-after
[CSS21] or the CSS3 break-before/break-after [CSS3-BREAK] properties
specify a fragmentation break.
从http://www.w3.org/TR/css-flexbox-1/ main-sizing
这听起来确实像(除了换行应该是为了打印的事实),当布局一个潜在的多行伸缩布局(我从规范的另一部分中获得的是一个没有flex-wrap: nowrap的布局)时,换行后的分页:always或换行后的分页:always应该引起换行,或换行到下一行。
.flex-container {
display: flex;
flex-flow: row wrap;
}
.child {
flex-grow: 1;
}
.child.break-here {
page-break-after: always;
break-after: always;
}
然而,我已经尝试过了,它还没有以这种方式实现……
Safari(最多7个)
Chrome(最多43 dev)
Opera(最多28人开发& 12.16)
IE(最多11名)
它确实像它听起来那样(至少对我来说):
Firefox (28 +)
样本在http://codepen.io/morewry/pen/JoVmVj。
我在漏洞跟踪器中没有发现任何其他请求,所以我在https://code.google.com/p/chromium/issues/detail?id=473481上报告了它。
但是这个话题被放到了邮件列表中,不管听起来如何,这显然不是他们想要暗示的,除了我猜的页码。因此,在flex布局中,如果不在flex子项中嵌套连续的flex布局,或者不修改特定的宽度(例如flex-basis: 100%),就无法在特定的盒子之前或之后进行换行。
This is deeply annoying, of course, since working with the Firefox implementation confirms my suspicion that the functionality is incredibly useful. Aside from the improved vertical alignment, the lack obviates a good deal of the utility of flex layout in numerous scenarios. Having to add additional wrapping tags with nested flex layouts to control the point at which a row wraps increases the complexity of both the HTML and CSS and, sadly, frequently renders order useless. Similarly, forcing the width of an item to 100% reduces the "responsive" potential of the flex layout or requires a lot of highly specific queries or count selectors (e.g. the techniques that may accomplish the general result you need that are mentioned in the other answers).
至少漂浮物是清晰的。人们希望在某个时候会为此添加一些东西。