I was experimenting with HTML and CSS, but I couldn't get it to function as desired.
What I am trying to achieve is that the first link/tab should appear pressed when the site is opened. It should then change to an unpressed state when another link is clicked. Additionally, there is a green line at the top which I want to change its color when a navigation tab/link is pressed simultaneously.
body {}
header {
position: fixed;
width: 100%;
border-top: 5px solid #8dc63f;
height: 120px;
background: white;
z-index: 1000;
border-bottom: 2px solid #fff;
top: 0;
}
h1 {
font-size: 70px;
color: red;
padding-top: 500px;
}
h2 {
font-size: 70px;
color: blue;
padding-top: 500px;
}
nav {
position: absolute;
right: -17px;
bottom: 0;
}
nav ul {
list-style: none;
}
nav ul li {
display: block;
float: left;
}
nav ul li a {
font-family: 'Open Sans', sans-serif;
margin-right: 2px;
color: white;
width: 100px;
padding: 10px;
display: block;
text-align: center;
position: relative;
text-decoration: none;
}
nav ul li a:hover {
color: #fff;
}
nav ul li a::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #8dc63f;
z-index: -1;
transform: skew(-40deg);
margin-bottom: -2px;
}
nav ul li a::before {
content: '+';
}
a:hover::after {
background: #cbda29;
}
HTML
<header>
<nav>
<ul>
<li><a href="#link1">Link1</a></li>
<li><a href="#link2">Link2</a></li>
<li><a href="#link3">Link3</a></li>
<li><a href="#link4">Link4</a></li>
</ul>
</nav>
</header>
<div id="link1">
<h1>Hello. I am Link1. If you see this the first link/button should stay pressed/clicked/lightgreen background until
you click another link. The top line "border-top" should change its color as well if you click a link.
</h1>
</div>
<div id="link2">
<h2>Oh hello i am the second link you clicked. The first button shouldn't be clicked anymore. Now link2 should appear
as a clicked button.
</h2>
</div>