【发布时间】:2017-05-12 13:18:54
【问题描述】:
最后一个<li>什么时候同时具有float和overflow属性,但仍然隐藏?
你可以删除float或者float属性看看效果。
我想知道为什么隐藏4元素,显示5元素;
.menu {
width: 300px;
line-height: 50px;
border: 2px solid #333;
padding: 0;
color: white;
}
.menu li {
float: left;
text-align: center;
list-style: none;
}
<ul class="menu">
<li style="width: 50%; background: red;">1</li>
<li style="width: 50%; background: blue;">2</li>
<!-- when the last one set both float and overflow it will hidden ? -->
<li style="float: none; overflow: hidden; background: #cdf;">4</li>
<li style="float: none; overflow: hidden; background: black;">5</li>
</ul>
【问题讨论】:
-
因为它没有宽度
-
但它有4个元素!
-
是的,你的溢出(文本)被隐藏了。
-
你为什么使用溢出:隐藏???
-
@kelen 您能否提供一个屏幕截图,说明 UI 的外观?