Here's what happening:
For my computer science class we're working on a project where we can only modify the CSS. I think it'd be super cool to change the content of the elements when you plug in my CSS file. Since I can't add a tag, I dont know how else can I do this. Here's what I have:
<div>
<h1>Is the makerspace door open?</h1>
</div>
<div>
<p id="switch_txt">Checking...</p>
</div>
</body>
I've tried using ::before and ::after pseudo selectors but these selectors can't place elements in the content property. Any advice would be much appreciated.
The text “Old Text” needs to be hidden first and a new text has to be positioned exactly where the old text was. To do so, we change the visibility of this text using CSS to hidden first. Then we add a new text at the exact same position, using the pseudo elements and corresponding explicit positioning.
By using text-indent: -999px; or a similar method, the text is still there — just not visually there. Use display:none , and the text is gone.
The best way to use is white-space: nowrap; This will align the text to one line.
The pseudo element is a good approach to visually replace text or insert an image.
text-indent can be useful added to a float context for the pseudo element to hide any dom inline or inline-block content(such as text or image).
Example:
HTML test
<h1>show me something else</h1>
CSS test
h1 {
text-indent:-9999px;
}
h1:before {
text-indent:0;
content:'Here is something else !';
float:left;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With