Single page website
I have a single page website (one page only). I can navigate with a menu to get to different parts of the page with anchor name, just like (see sidebar):
WordPress Docs
Hide the other stuff
I want to hide stuff that does not belong the the current active page part and just show the information of the part that I'm looking at.
Question(s)
You can hide an element in CSS using the CSS properties display: none or visibility: hidden . display: none removes the entire element from the page and mat affect the layout of the page. visibility: hidden hides the element while keeping the space the same.
To disable a HTML anchor element with CSS, we can apply the pointer-events: none style. pointer-events: none will disable all click events on the anchor element. This is a great option when you only have access to class or style attributes. It can even be used to disable all the HTML links on a page.
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.
<a href="#"><a name=""> The A element defines an anchor. You can create a link to a named anchor by using the name attribute (or the id attribute). When linking within the same document, the A element is set as follows. Anchor names must be unique within a document.
Working Example
Try this Html
<a href="#a">a</a>
<a href="#b">b</a>
<a href="#c">c</a>
<div id="a" class="page"> this is a id</div>
<div id="b" class="page"> this is b id</div>
<div id="c" class="page"> this is c id</div>
and Css
#a, #b, #c{
display:none;
}
#a:target{
display:block;
}
#b:target{
display:block;
}
#c:target{
display:block;
}
yes you can do this with only css,first creat < div > with a specific width and height and overflow to hidden,then place your stuff in this div beside eachother
<a href="#firstWindow">firstWindow</a>
<a href="#secondWindow">secondWindow</a>
<a href="#thirdWindow">thirdWindow</a>
<div class="window">
<div id="firstWindow" class="window">
firstWindow
</div>
<div id="secondWindow" class="window">
secondWindow
</div>
<div id="thirdWindow" class="window">
thirdWindow
</div>
</div>
.window{
width:300px;
height:300px;
overflow:hidden;
}
something like above; note that you can use this html/css if you have a constant height,the height of your stuff should be the same.
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