Getting :before pseudo element to use background image of parent
-
25-10-2019 - |
Question
Can CSS be used to set the background image of a :before pseudo element to the same as it's parent. I want to say inherit, but can a pseudo element inherit anything? Example:
li a {
background: #f56a46 url(images/gallery-thumb.jpg) center center no-repeat;
}
li a:before {
background: inherit;
}
I know I could easily do it with JavaScript but I want to know if it's possible using only CSS. Any help would be much appreciated, Thanks!
Solution
Inherit
must work for pseudo-elements: http://jsfiddle.net/kizu/GaUsp/
Are sure, you've added all the needed properties like content
, display
and dimensions so the pseudo-element have a box where background must be shown?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow