html - 在没有容器的情况下强制溢出隐藏
问题描述
这是我的 HTML 和 CSS(基本原理):
.tall-element:before {
height: 2000px;
position: absolute;
bottom: 0;
background-color: #000;
width: 10px;
display: block;
content: " ";
}
<ul>
<li>
</li>
<li class="element-i-want-do-use-to-hide">
</li>
<li class="tall-element">
</li>
</ul>
这(故意)创建了一条我希望能够设置overflow:hidden
为.element-i-want-do-use-to-hide
元素的线,但我不能完全做到这一点。
我可以设置overflow-y: hidden
为<ul>
and 这将导致线路中断,这是我正在寻找的效果,除了我想将该中断应用于相邻元素(在本例中为.element-i-want-do-use-to-hide
元素)。
有人知道这样做的方法吗?
解决方案
你的意思是这样吗?
.tall-element:before {
height: 2000px;
position: absolute;
bottom: 0;
background-color: #000;
width: 10px;
display: block;
content: " ";
}
.element-i-want-do-use-to-hide {
position: relative;
}
.element-i-want-do-use-to-hide:before {
height: 2000px;
position: absolute;
z-index: 1;
top: 0;
background-color: #FFF;
width: 10px;
display: block;
content: " ";
}
<ul>
<li>
</li>
<li class="element-i-want-do-use-to-hide">
</li>
<li class="tall-element">
</li>
</ul>
推荐阅读
- unity3d - Is there a fast way to detect drag events on a game object in Unity?
- python - to_excel() 没有索引布局
- angular - 动态表的页脚值 - Angular
- javascript - 节点 JS 部署
- node.js - Node.js:将 Cucumber JSON 结果发送到 Jira 的 Xray - jira-client-xray 给出 HTTP 405 错误
- r - limma:smooth.spline 中的错误(lambda,pi0,df = smooth.df):不允许输入中的缺失或无限值
- google-apps-script - 谷歌工作表脚本 - 复制并放置一个单元格值
- java - 咖啡因缓存:永远不会调用 write()
- linux-kernel - `ioctl` 读写 GPIO:无效参数
- masm - 我无法在 masm x86 中进行选择排序