CSS set content of element to image -
i've got following class, works in major browsers except firefox pc. issue content
being on regular element—ffx doesn't seem on except ::before
or ::after
pseudo-element. trouble is, ::after
not inherit size of base element.
html
<span class="col-3 myimg"></span>
css
.col-3 { width: 25%; } .myimg { /* content: url('img.png'); works in ffx on pc */ display: block; position: relative; } /* v needed ffx on pc */ .myimg::after { background: red; content: url('img.png'); display: block; max-width: 100%; /* affects background colour */ position: absolute; width: 100%; /* affects background colour */ }
i don't want set height—i want height stay proportional width (which determined col-#
bootstrap v3).
i don't want use bunch of image tags because means update require bunch of edits (instead of 1 central 1 css).
related question: can change height of image in css :before/:after pseudo-elements?
edit want image 100% width of base element (the span) , image's height scale proportionately.
Comments
Post a Comment