css - Cant get the pseudo class before to work -


so here's i'm trying do,

i want add top background strip(of height 30px) how stackoverflow has using pseudo class before. know can done without i'm interested know if can accomplished using :before pseudo class.

here's code,

<div class="container"> //other divs </div> 

and here's css i'm using,

.container:before { content: " "; background-image:url(../images/head-bg.jpg); background-repeat:repeat-x; min-height:30px; } 

i read somewhere content: " "; needs added pseudo class work i've added nothing in quotes.

i've tried removing background code css , adding text within content quotes , works. however, when add code background doesn't.

i'll grateful if point out mistake doing this.

thanks time.

you should set width of .container whatever need be. should use height instead of min-height. :before , :after pseudo elements display:inline default, in order height , width applied you'll need change display.

demo

.container:before {     content: "";     background-image:url(../images/head-bg.jpg);     background-repeat:repeat-x;     height:30px;     width:30px;     display:inline-block; } 

also can use empty string content.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -