overflow hidden 的CSS

标签 css

如何显示 div 容器的最后一个可见的 li 元素,另外说“overflow:hidden” - 将它对齐到底部?

<ul style="height:20px; overflow:hidden;">
<li>1</li>
<li>2</li>
<li>3</li>
<li>this eventually should be visible</li>
<li>this should be visible</li>
</ul>

最佳答案

我不确定这样做的目的是什么,或者你打算如何显示其他 li 但是......Flexbox 可以做到这一点。

ul {
  list-style-type: none;
  border: 1px solid grey;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 20px;
  overflow: hidden;
  font-size: 16px;
  line-height: 20px;
}
<ul>
  <li>1</li>
  <li>2</li>
  <li>3</li>
  <li>this eventually should be visible</li>
  <li>this should be visible</li>
</ul>

关于 overflow hidden 的CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36609690/

相关文章:

html - 如何仅使用 CSS 隐藏未被标签包裹的内容?

javascript - 如何使用 Jquery 切换 anchor 文本?

html - 如何将 div 包裹在不均匀的内容周围

html - 如何增加无限跳跃 CSS 动画之间的延迟?

html - 当最大高度从 0 增加时,最大高度上的 CSS 过渡不会缓解(纯 CSS)

边框内的 HTML CSS 颜色

c# - 如何使用 C# 从 DIV 中抓取图像

html - 为什么 margin top 在 anchor 标签中不起作用,但在按钮中起作用?

css - 横幅 <div> 不会在 IE9 中显示,但会在 Chrome 中显示

jquery - 如何将无序列表转换为表格?