gpt4 book ai didi

css - Firefox/IE 的间隙/边距问题

转载 作者:太空宇宙 更新时间:2023-11-04 16:12:52 25 4
gpt4 key购买 nike

我希望有一堆包含文本的矩形,它们并排放置,并在必要时换行到下一行。我为每个矩形设置了最大宽度,任何不适合矩形的文本都应该被隐藏。

这是我写的代码

HTML

<div id="outer">
<ul id="list">
<li>The name of soemthing</li>
<li>Something else</li>
<li>Something else 2</li>
<li>Something else 3 </li>
<li>Something else 4</li>
</ul>
</div>

CSS

#outer {
background-color: #0000ff;
width: 500px;
}

#list {
margin: 0px;
padding: 0px;
list-style-type: none;
}

#list li {
display: inline-block;
max-width: 100px;
overflow: hidden;
white-space:nowrap;
height: 24px;
padding: 0px;
background: #ff0000;
margin: 0px;
}

它在 Chrome 中完美运行。

在 Firefox/IE 中,每个矩形之间添加了一个小的垂直间隙/边距。

我可以通过删除 LI 元素上的“溢出:隐藏”来消除间隙,但这当然允许矩形自由增长 - 这是我试图避免的。

有人知道为什么会这样吗?

最佳答案

尝试将所有 <li>标签在同一行。浏览器将换行符呈现为空白。

<div id="outer">
<ul id="list">
<li>The name of soemthing</li><li>Something else</li><li>Something else 2</li><li>Something else 3</li><li>Something else 4</li>
</ul>
</div>

关于css - Firefox/IE 的间隙/边距问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8043345/

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