grm 3

Is it possible to center an image in a before pseudo class?

Something like:

.rap {background: url("img/rap.jpg") repeat-y scroll center center;}
.rap:before {content: url("img/rapbf.jpg");}

Here I want the rapbf.jpg also centered and not only rap.jpg.

1 answer

Sisira 95

Just try adding the rule text-align:center to the .rap class. May be this would be the case what you want to achieve. And if you want paragraphs left align in that div add text-align:left.

So the final code would be as follows .rap {background: url("img/rap.jpg") repeat-y scroll center center; text-align:center} .rap p{text-align:left} .rap:before {content: url("img/rapbf.jpg");}

Answered over 8 years ago by Sisira