[英]Pseudo element :before and overflow hidden
I have a element which has two borders. 我有一个有两个边框的元素。 I achieved that by adding a pseudo element:
我通过添加一个伪元素实现了这一点:
.inner:before {
width: 72px;
height: 28px;
content: '';
display: block;
border: 3px solid rgb(255, 0, 0);
position: absolute;
}
The element is wrapped with another div which has the property overflow: hidden
. 该元素用另一个div包装,该div具有
overflow: hidden
属性。
As you can see here: http://jsfiddle.net/HKEn4/1/ the .inner-element is hidden but not the pseudo element (tested with safari, firefox and chrome on OSX). 正如你在这里看到的: http : //jsfiddle.net/HKEn4/1/ .inner元素是隐藏的,但不是伪元素(在OSX上使用safari,firefox和chrome进行测试)。
How can I hide the pseudo element? 如何隐藏伪元素?
I added position: relative;
我添加了
position: relative;
in the .wrapper
class and it works! 在
.wrapper
类中,它的工作原理!
See fiddle: http://jsfiddle.net/HKEn4/2/ 见小提琴: http : //jsfiddle.net/HKEn4/2/
从:before
伪元素中删除position:absolute
;或者position:relative
对于容器添加position:relative
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.