Change .circle:hover to .hover
.hover { background:orange; transition: all 0.5s ease }
A) If you want the orange color to be forever:
Use jquery
$(document).ready(function(){ $('.circle').hover(function(){ $(this).addClass('hover'); }) })
$(document).ready(function(){ $('.circle').hover(function(){ $(this).addClass('hover'); }) })
.container{ background: white; display:flex; justify-content: center; align-items: center; height:50px } .circle { display: inline-block; width: 20px; height: 20px; background: #0f3757; -moz-border-radius: 50px; -webkit-border-radius: 50px; border-radius: 50px; margin-left:10px; float:left; transition: all 0.5s ease } .hover { background:orange; transition: all 0.5s ease }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <div class= "container"> <span class="circle"></span> <span class="circle"></span> <span class="circle"></span> <span class="circle"></span> </div>
B) If you want the orange color to be until the mouse moves to another circle
Use jquery
$(document).ready(function(){ $('.circle').hover(function(){ $('.circle').removeClass('hover'); $(this).addClass('hover'); }) })
$(document).ready(function(){ $('.circle').hover(function(){ $('.circle').removeClass('hover'); $(this).addClass('hover'); }) })
.container{ background: white; display:flex; justify-content: center; align-items: center; height:50px } .circle { display: inline-block; width: 20px; height: 20px; background: #0f3757; -moz-border-radius: 50px; -webkit-border-radius: 50px; border-radius: 50px; margin-left:10px; float:left; transition: all 0.5s ease } .hover { background:orange; transition: all 0.5s ease }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <div class= "container"> <span class="circle"></span> <span class="circle"></span> <span class="circle"></span> <span class="circle"></span> </div>
source share