我有水平滚动列。里面有一些带有标题的文本。我需要让每个标题生成一个新列并占用属于它的列上方的所有空间:
但我能做的最好的事情是(顺便说一下,它在 Firefox 中失败了):
我尝试使用inline-block
s存档所需的结果,但那里出现了另一个问题。我还尝试了一些负边距、绝对定位和 的方法transform
,但没有成功:它们不允许超出列(除了absolute
容器上下文:它忘记了基于列的水平定位)。
最简单的代码https://jsfiddle.net/07n6L2yh/10/
.container {
outline: 1px dotted gray;
height: 200px;
-moz-column-width: 10em;
column-width: 10em;
-moz-column-fill: auto;
column-fill: auto;
overflow-x: auto;
}
h2 {
break-before: column; /* Firefox? */
border-bottom: 1px solid;
margin: 0 0 .25em;
}
p {
margin: 0;
}
<div class="container">
<h2>Lorem ipsum</h2>
<p>Lorem ipsum dolor sit amet, eu eirmod complectitur pri, agam libris euripidis no quo. In cum adolescens necessitatibus, et hinc nominati indoctum his, idque prompta moderatius cu per. Quo ei novum utroque, ius ex graecis volutpat quaerendum! Ea assum erroribus accommodare pri, simul omnesque scaevola has cu, an putant tacimates ius. Ius soluta nonumes ei? Ex modus eligendi repudiandae ius, nec cu quem delicatissimi.</p>
<h2>AAA</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur, explicabo.</p>
<h2>Dolor sit</h2>
<p>Lorem ipsum dolor sit amet, eu eirmod complectitur pri, agam libris euripidis no quo. In cum adolescens necessitatibus, et hinc nominati indoctum his, idque prompta moderatius cu per. Quo ei novum utroque, ius ex graecis volutpat quaerendum!</p>
<h2>BBB</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
<h2>CCC</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
</div>
更复杂的版本:https ://jsfiddle.net/07n6L2yh/11/
PS:俄语中的同样问题。