我的CSS
ul{
overflow:hidden;
}
li{
display:inline-block;
}
我的 HTML
<ul>
<li>a</li>
<li>b</li>
<li>c</li>
<li>d</li>
<li>e</li>
<li>f</li>
<li>g</li>
</ul>
我想将我所有的 li 项目排成一行,如果我这样做,一切正常,除了当 3 或 4 li 填充我身体的第一行时,它们进入第二行,我希望它们在 1 行和所有内容第 1 行填充后将被“隐藏”
例如 ::
// 注意 li 持有的句子不只是 1 个字母
现在输出:
a b c d
e f g
期望的输出:
a b c d e f //all of them in 1 line and the rest of them are hidden 'overflow:hidden'
原文由 trrrrrrm 发布,翻译遵循 CC BY-SA 4.0 许可协议
尝试将
white-space:nowrap;
放入你的<ul>
风格编辑:并使用“内联”而不是其他人指出的“内联块”(我忘了)