I have a sidenav with some menu items, right now I have an active class applied to the current li, it will highlight the li with a background color (in this case: #3596d5).
Instead of highlighting the entire li, I should like just a tiny section (about 10 pixels) to the left of the text to be highlighted, I can’t think of any way to do this.
Here is the photoshopped result that I am looking for:
My current HTML:
<nav class="nav-primary">
<ul class="nav nav-main">
<li class="active">
<a class="auto nav-item text-white" href="#">
<span>Home</span>
</a>
</li>
<li class="">
<a class="auto nav-item" href="#">
<span>Item 2</span>
</a>
</li>
<li class="">
<a class="auto nav-item" href="#">
<span>Item 3</span>
</a>
</li>
<li class="">
<a class="auto nav-item" href="#">
<span>Item 4</span>
</a>
</li>
<li class="">
<a class="auto nav-item" href="#">
<span>Item 4</span>
</a>
</li>
</ul>
</nav>
My current CSS:
.text-white {
color: white;
}
.nav-primary ul.nav > li > a {
padding: 15px
}
nav {
background-color: black;
}
.active {
background-color: #3596d5;
}
My jsfiddle is here (This is using bootstrap external resource)
Any help would be appreciated.
3
Answers
You can use a gradient background:
http://jsfiddle.net/vtp7omx2/1/
Add this to your CSS:
see fiddle
You could use ::before like this:
See fiddle http://jsfiddle.net/vtp7omx2/3/