Use pseudo-elements on replaced elements
If you want to use the :after or :before on replaced elements (e.g. img or input) you can use the following hack:
Enable the pseudo element for the img with an empty content property on the img itself:
img {
content: '';
}
Add the pseudo element to the img:
img:after {
content: 'Pseudo Content, Yeah';
}
Example
Browser Support
- Chrome 10+
- Firefox 11+
- Opera 9.8+
- Safari
Further reading
Written by Tim Pietrusky
Related protips
1 Response
Nice for img elements - doesn't seem to work on inputs though (which the description led me to believe).
Nice workaround, nonetheless!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#