content
is only supposed to be used on pseudo-elements (:before
and :after
).
It can only be used with the pseudo elements :after and :before.
(According to CSS-Tricks)
Somehow, it works on normal elements too, but only in WebKit-Browsers like Chrome and Safari, as you noticed.
But only works on webkit browsers like chrome and safari.
(According to George Nava on CSS-Tricks)
Solutions
Some simple solutions:
Use :before
:
CSS:
div.clearearlanding:before {
content: url('/images/clearearlandingpage.png');
margin-left: -70px;
width: 120%;
}
Use an img
tag (although you probably had your reasons to not use that):
CSS:
div.clearearlanding > img {
margin-left: -70px;
width: 120%;
}
HTML:
<div class="clearearlanding">
<img src="https://placeholdit.imgix.net/~text?txtsize=48&txt=512%C3%97256&w=512&h=256" />
</div>
Or use background-image
on either .clearearlanding
or its :before
element.