cur*_*urt 5 html css column-count
我正在使用 css column-count 功能将我的部分分成两列。在一个页面上,我在第一列的底部有一个 h3 标题,在下一列的顶部有下面的 p 段落。我想保留段落的前几句话的标题。我可以将它与整个段落一起包装在一个带有内联块样式的 div 中。这适用于短段落,但不适用于长段落。我也可以随意拆分段落,但如果在标题之前添加了额外的内容,我可能不得不将其重新组合在一起,迫使它进入下一列。如果不可能,因为列数是新的,我不会感到惊讶。
更新
根据下面@Jon 的建议,我尝试从网上找到的示例中闯入,因为我知道了关键字。
CSS:
.heading-with-text {
-webkit-column-break-inside: avoid;
-moz-column-break-inside: avoid;
break-inside: avoid;
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<section class="heading-with-text">
<h3>Blah, Blah</h3>
<p>woof, woof</p>
</section>
Run Code Online (Sandbox Code Playgroud)
在 OS X 平台上,它在 Firefox 24.0 中根本不起作用。在 Safari 6.0.5 和 Chrome 30.0.1599.66 中,它将标题移动到下一列,使其位于文本上方。但是,无论我在段落中添加多少文本,浏览器都不会在段落中打断。它就像内联块一样工作。我猜他们把“避免”理解为不惜一切代价避免。这种方法似乎是正确的方法。只是目前没有得到很好的支持。
div将标题及其相应内容放在 a 中,而不是a 中section:
<section>\n <h3>Keep a Heading with the Following Text</h3>\n <p>I\xe2\x80\x99m using the CSS <code>column-count</code> feature\xe2\x80\xa6\n</section>\nRun Code Online (Sandbox Code Playgroud)\n\n而不是display: inline-block使用column-break-inside: avoid. 这应该暗示分列算法不要跨列边界分割内容。
| 归档时间: |
|
| 查看次数: |
3927 次 |
| 最近记录: |