change the color of an element on mouse hover - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Hover to change Color

Description

change the color of an element on mouse hover

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">

* {<!--from   ww w. jav a2s  . com-->
   text-align: center;
   margin: 0;
   padding: 0;
}
button[type=submit] {
   padding: 20px 30px;
   background-color:black;
   border: 0;
   position: relative;
   color: #ffe200;
   font-size: 22px;
}
button[type=submit]:after {
   content: '';
   border-width: 23px;
   border-color: transparent black black transparent;
   border-style: solid;
   position: absolute;
   top: 9.5px;
   left: 228px;
   -webkit-transform: rotate(-45deg);
   -ms-transform: rotate(-45deg);
   transform: rotate(-45deg);
}
button[type=submit]:hover {
   color: black;
   background-color: #ffe200;
   border-color: transparent #ffe200 #ffe200 transparent;
}
button[type=submit]:hover:after {
   border-color: #ffe200;
   z-index: -1;
}


      </style> 
 </head> 
 <body> 
  <button type="submit">Submit</button>  
 </body>
</html>

Related Tutorials