How can I replace text with css using a method like this:
.pvw-title img[src*="IKON.img"] { visibility:hidden; }
Instead of ( img[src*="IKON.img"]
), I need to use something that can replace text instead.
I have to use [
]
to get it to work.
<div class="pvw-title">Facts</div>
I need to replace "Facts".
I had better luck setting the
font-size: 0
of the outer element, and thefont-size
of the:after
selector to whatever I needed.It may not perfectly answer the question, but it satisfied my needs and maybe others too.
So if you just want to show different texts or images, keep the tag empty and write your content in multiple data attributes like that
<span data-text1="Hello" data-text2="Bye"></span>
. Display them with one of the pseudo classes:before {content: attr(data-text1)}
Now you have a bunch of different ways to switch between them. I used them in combination with media queries for a responsive design approach to change the names of my navigation to icons.
jsfiddle demonstration and examples
Text Replacement with Pseudo-elements & CSS Visibility
HTML
CSS
If you're willing to use pseudo elements and let them insert content, you can do the following. It doesn't assume knowledge of the original element and doesn't require additional markup.
JSFiddle Example
Simple, Short, Effective. No additional html necessary.
I had to do this for replacing link text, other than home, for woocommerce breadcrumbs
SASS/LESS
CSS