【发布时间】:2022-01-17 02:08:31
【问题描述】:
我希望我的 before 或 after 元素显示在 div 之外。请注意,这个父 div 必须是具有自动溢出或滚动功能的滚动元素,但是 div 函数的输出将其禁用。
它应该看起来像在右侧,但带有滚动功能:
.container {
display: flex;
}
.parent {
width: 100%;
height: 50px;
background: black;
margin: 10px;
}
.of {
overflow: auto;
}
p {
color: white;
position: relative;
}
p::after {
position: absolute;
bottom: -8px;
left: -16px;
content: '';
height: 2px;
background: green;
width: 2.313rem;
}
<div class="container">
<div class="parent of">
<p>Text</p>
<p>Text</p>
<p>Text</p>
<p>Text</p>
</div>
<div class="parent">
<p>Text</p>
<p>Text</p>
<p>Text</p>
<p>Text</p>
</div>
</div>
【问题讨论】:
-
我很困惑,你想让右侧镜像左侧吗?
-
如果这个父元素的溢出值为滚动或自动(可滚动),我希望我的前/后元素离开父元素。左边的部分只是为了表明溢出功能可以防止这种情况。右边应该代表它可以从父项中溢出而没有溢出
-
右侧图像上发生的事情是所有内容都溢出(包括文本 - 你只是看不到它,因为它是白色背景上的白色)。你能解释更多你真正想要什么吗?是所有的 p 元素都在溢出中还是只有绿线?
标签: html css pseudo-element