css - Why do I need an empty `content` property on an ::after pseudo-element? -


this question has answer here:

i got http://jsfiddle.net/8p2wx/2/ previous question asked , see these lines:

.cf:before, .cf:after {     content:"";     display:table; }  .cf:after {     clear:both; } 

if take away content:"", ruins effect, , don't understand why it's necessary.

why needed add empty content :after , :before pseudo-elements?

you cannot style generated content without defining content should be. if don’t need content, “invisible element” style, can set empty string (content: '') , style that.

it’s easy confirm yourself: http://jsfiddle.net/mathias/yrm5v/

by way, snippet posted micro clearfix hack, explained here: http://nicolasgallagher.com/micro-clearfix-hack/

as second question, you’ll need an html5 shiv (small piece of javascript) make <nav> stylable in older browsers.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -