gpt4 book ai didi

css - 多行跨度行为元素

转载 作者:太空狗 更新时间:2023-10-29 13:20:57 26 4
gpt4 key购买 nike

我想显示一个复杂但固定大小的多行元素列表,假设当到达行尾时它们将换行,使它们在每一行中按 n 出现,当n 取决于页面宽度。像这样的东西:

Mary had    Mary had    Mary had
a little a little a little
LAMB LAMP WHISKEY


Mary had
a little
TOO MUCH

我应该怎么做?

最佳答案

inline-block spans 应该这样做:

body {
font-family: sans-serif;
}
#container span {
display: inline-block;
width: 5em;
border: 1px solid black;
}
<div id='container'>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
<span>Mary had a little lamb</span>
</div>
</body>

</html>

关于css - 多行跨度行为元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2410135/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com