i'm pretty new to coding (just started a free weeks ago with html and css). For a news page i tried to implement "read on" links, similiar to this question here: on click hide this (button link) pure css
However i can't seem to make the link disappear after clicking it. I got this for my code so far (opening and closing works just fine):
.readmore {
display: none;
}
article[id*="n"]:target .readmore {
display: block;
}
article:target .used {
display: none;
}
<article>Text visible after you open the site.
<a href="#n2" class="used">Link that opens more text and should diappear after clicking</a>
<article id="n2">
<div class="readmore">more text
<a href="#back">Closing button</a>
</div>
</article>
</article>
I feel like i messed something up big time, but i really can't figure it out.
Use CSS styling to make your links invisible The first way is by using none as the pointer-events CSS property value. The other is by simply coloring the text to match the background of the page. Neither method hides the link if someone inspects the HTML source code.
The css input:checked+div selects the div immediately next to/after the input. The label for said checkbox (or hey leave out the label and just have the checkbox) display:none hides stuff.
By changing the display feature to "none", you will remove the link from the page layout. This may cause other elements of your page to move if they define their position in reference to your link. Changing your visibility to "hidden" will hide the link without influencing the page layout.
Just put your link inside the article tag including your id.
.readmore {
display: none;
}
article[id*="n"]:target .readmore {
display: block;
}
article[id*="n"]:target .used {
display: none;
}
<article>Text visible after you open the site.
<article id="n2">
<a href="#n2" class="used">Link that opens more text and should diappear after clicking</a>
<div class="readmore">more text
<a href="#back">Closing button</a>
</div>
</article>
</article>
Using this you can achieve what you want.....you have added id inner article which you have to give parent artical and change css
.readmore {
display: none;
}
#n2:target .readmore {
display: block;
}
#n2:target .used {
display: none;
}
.readmore {
display: none;
}
#n2:target .readmore {
display: block;
}
#n2:target .used {
display: none;
}
<article id="n2">Text visible after you open the site.
<a href="#n2" class="used">Link that opens more text and should diappear after clicking</a>
<article>
<div class="readmore">more text
<a href="#back">Closing button</a>
</div>
</article>
</article>
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