You have two options:
Using pseudo-elements (remove border with #spanRed ):
#spanRed:after { content:' '; display:block; position:absolute; left:0; top:0; right:0; bottom:0; border:4px solid red; }
Remember that using position:fixed as the basis for the layout is very fragile.
to change . If you need IE7 support, add an additional element via JS:
$('#spanRed').append('<span class="after" />')
Then specify it in CSS. Keep in mind that you need to repeat the whole style, you cannot use both selectors together, otherwise IE7 ignores the rule.
Or, since these are all "useless" elements, just add it to your HTML:
<div id="spanRed"> <span class="inner"></span> </div>
Here is your code using this: http://jsfiddle.net/eh9rM/2/
source share