25

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.

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).

How can I hide the pseudo element?

3
  • See jQuery and pseudo-elements Commented Oct 15, 2013 at 8:35
  • What's the absolute positioning on the pseudo element good for? Commented Oct 15, 2013 at 8:39
  • 1
    @CBroe It certainly helped create the overflow problem. Commented Oct 15, 2013 at 8:42

2 Answers 2

38

I added position: relative; in the .wrapper class and it works!

See fiddle: http://jsfiddle.net/HKEn4/2/

Sign up to request clarification or add additional context in comments.

1 Comment

Note: if .inner contains ANY transform, the pseudo-element will get clipped. Demo
5

Either remove the position:absolute from the :before pseudo-element, or add position:relative to the container..

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.