Looking to design a responsive sidebar for navigation on my page, with selected and hover properties. Visualizing the selected option to appear like this:
Selected (active) option in sidebar
The goal is to have the image cover the left side of the background when selected. Here's what I've tried so far:
.sidebarNav {
background-color: white;
padding: 10px 10px;
border-radius: 5px;
}
.sidebarNav li {
padding: 15px 10px;
margin: 5px;
}
.sidebarNav li img {
transition: transform .7s ease-in-out;
height: 50px;
width: 50px;
}
.sidebarNav li img:hover {
transform: rotate(360deg);
}
.sidebarNav li:hover {
background-color: #4D5BBE;
cursor: pointer;
border-radius: 10px;
}
.sidebarNav li:hover img {
transform: rotate(360deg);
}
.sidebarNav li:hover>div {
display: block;
}
.sidebarNav li .active {
background-color: #417fbd;
padding: 5px 10px !important;
}
.sidebarNav li:active a {
color: white;
}
.sidebarNav a {
color:black;
text-decoration: none;
padding: 0 20px;
}
.sidebarNav li:hover a {
color: white;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d2b0bdbda6a1a6a0b3a292e7fce0fce2ffb0b7a6b3e3">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>
<ul class="sidebarNav nav navbar-nav">
<li class="active">
<span><img src="https://cdn-icons-png.flaticon.com/512/287/287221.png?w=360"/></span><a href="#"> Ranks</a>
</li>
<li><a href="">Rank Upgrades</a></li>
<li><a href="">PokeBoxes</a></li>
<li><a href="">Crate Keys</a></li>
<li><a href="">Kits</a></li>
<li><a href="">Plushies</a></li>
<li><a href="">Commands</a></li>
<li><a href="">PokePass</a></li>
<li><a href="">Miscellaneous</a></li>
<li><a href="">Shiny Party</a></li>
</ul>
Expanding on Telman's response...
Wanting to shift active li properties to the currently hovered li, removing them from the .active li.
If hovering over "Rank Upgrades," for instance, it should take on the background and image instead of the current .active li. How can this be achieved?