Having trouble creating a custom CSS navigation for my website. Below is the code snippet of my attempt at a vertical navigation:
<style type="text/css">
/* Custom stylesheet */
#cssmenu > ul {
list-style: none;
margin: 0;
padding: 0;
vertical-align: baseline;
line-height: 1;
}
/* Container styling */
#cssmenu > ul {
display: block;
position: relative;
width: 150px;
}
/* List elements containing links */
#cssmenu > ul li {
display: block;
position: relative;
margin: 0;
padding: 0;
width: 250px;
}
/* Link styles */
#cssmenu > ul li a {
/* Layout */
display: block;
position: relative;
margin: 0;
border-top: 1px dotted #3a3a3a;
border-bottom: 1px dotted #1b1b1b;
padding: 11px 20px;
width: 210px;
/* Typography */
font-family: Helvetica, Arial, sans-serif;
color: #d8d8d8;
text-decoration: none;
text-transform: uppercase;
text-shadow: 0 1px 1px #000;
font-size: 13px;
font-weight: 300;
/* Background & effects */
background: #282828;
}
/* Hover state styling */
#cssmenu > ul li>a:hover, #cssmenu > ul li:hover>a {
color: #000;
text-shadow: 0 1px 0 rgba(0, 0, 0, .3);
background: #A9CA6F;
background: -webkit-linear-gradient(bottom, #A9CA6F, #B4D876);
background: -ms-linear-gradient(bottom, #A9CA6F, #B4D876);
background: -moz-linear-gradient(bottom, #A9CA6F, #B4D876);
background: -o-linear-gradient(bottom, #A9CA6F, #B4D876);
border-color: transparent;
}
</style>
Struggling to make the clicked link change its background to #A9CA6F. I want the <li>
with an active id/class to maintain this color. Any insights?
Thanks in advance!
Feel free to check out the demo on JSFiddle here.