Issues : You have not changed your background colors on hover
and active
states. See
.our-work-side-menu ul li:hover {
background-color: #529883; /*Same Color */
}
.our-work-side-menu ul li a {
color: #529883;
}
.our-work-side-menu ul li a:hover { /* Repeated | Redundant CSS */
color: #ffffff;
background-color: #529883; /*Same Color */
}
.our-work-side-menu a:active {
color: #ffffff;
background-color: #529883; /*Same Color */
}
Fixes:
.et_pb_sidebar_0.et_pb_widget_area {
border: 1px solid #a9a9a9;
}
.et_pb_sidebar_0.et_pb_widget_area .widgettitle {
padding-left: 30px;
}
.our-work-side-menu ul li {
box-sizing: border-box;
margin: 0;
border-top: 1px solid #a9a9a9;
width: 100%;
}
.our-work-side-menu ul li a {
color: #529883;
display: block;
height: 100%;
text-decoration: none;
padding: 10px 0 10px 40px;
}
.our-work-side-menu ul li a:hover {
color: #ffffff;
background-color: #529883;
}
.our-work-side-menu ul li a:active {
color: #ffffff;
background-color: orange;
}
/* UPDATE: For clicked link behaviour we set an active class */
.active {
background: orange;
color: #ffffff !important;
}
UPDATE :
JAVASCRIPT:
For Clicked Link to have the active style, we need to use a bit of CSS. I have come up with this code (though) there are many approaches :)
document.addEventListener("DOMContentLoaded", () => {
let linksWrapper = document.querySelector(".links-wrapper");
let hiddenLI = document.createElement("li");
let anchor = document.createElement("a");
anchor.setAttribute("class", "active");
hiddenLI.appendChild(anchor);
linksWrapper.appendChild(hiddenLI);
hiddenLI.style.display = "none";
const mainLinks = document.querySelectorAll(".links-wrapper li a");
for (var i = 0; i < mainLinks.length; i++) {
mainLinks[i].addEventListener("click", function () {
var current = document.getElementsByClassName("active");
current[0].className = current[0].className.replace("active", "");
this.className = "active";
});
}
});
FULL WORKING CODE:
document.addEventListener("DOMContentLoaded", () => {
let linksWrapper = document.querySelector(".links-wrapper");
let hiddenLI = document.createElement("li");
let anchor = document.createElement("a");
anchor.setAttribute("class", "active");
hiddenLI.appendChild(anchor);
linksWrapper.appendChild(hiddenLI);
hiddenLI.style.display = "none";
const mainLinks = document.querySelectorAll(".links-wrapper li a");
for (var i = 0; i < mainLinks.length; i++) {
mainLinks[i].addEventListener("click", function () {
var current = document.getElementsByClassName("active");
current[0].className = current[0].className.replace("active", "");
this.className = "active";
});
}
});
.et_pb_sidebar_0.et_pb_widget_area {
border: 1px solid #a9a9a9;
}
.et_pb_sidebar_0.et_pb_widget_area .widgettitle {
padding-left: 30px;
}
.our-work-side-menu ul li {
list-style: none;
box-sizing: border-box;
margin: 0;
border-top: 1px solid #a9a9a9;
width: 100%;
}
.our-work-side-menu ul li a {
color: #529883;
display: block;
height: 100%;
text-decoration: none;
padding: 10px 0 10px 40px;
}
.our-work-side-menu ul li a:hover {
color: #ffffff;
background-color: #529883;
}
.our-work-side-menu ul li a:active {
color: #ffffff;
background-color: orange;
}
.active {
background: orange;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="our-work-side-menu">
<ul class="links-wrapper">
<li><a href="#">Completed Projects</a></li>
<li><a href="#">Ongoing Projects</a></li>
<li><a href="#">Future Projects</a></li>
<li><a href="#">Photo Gallery</a></li>
<li><a href="#">Video Center</a></li>
<li>
<a href="#">Dr. Asamoah Bio Video</a>
</li>
</ul>
</div>
</body>
<script src="./script.js"></script>
</html>