如何阻止伪元素受父元素悬停的影响?
.list-item {
position: absolute;
background: black;
color: white;
padding: 10px 20px;
transition: all 250ms ease-in-out;
}
.list-item:hover {
transform: scale(1.5);
}
.list-item:after {
content: '';
position: absolute;
width: 20px;
height: 20px;
background: orange;
z-index: 10;
border-radius: 100%;
}
<div class="list-item">
test
</div>
悬停时,它将所有悬停效果应用于:after伪元素
1条答案
按热度按时间b09cbbtk1#
一种方法可以是对
::after
伪元素应用相反的过渡: