Hover link to change whole page background color with css - HTML CSS CSS Property

HTML CSS examples for CSS Property:background-color

Description

Hover link to change whole page background color with css

Demo Code

ResultView the demo in separate window

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

body {<!--   w w w  . j  a v a  2  s  . c o m-->
   background: lightblue;
}
a:hover:before {
   content: '';
   position: absolute;
   display: block;
   top: 0; bottom: 0; left: 0; right: 0;
   z-index: -1;
}
li:nth-of-type(1) a:hover:before {
   background-color: blue;
}
li:nth-of-type(2) a:hover:before {
   background-color: red;
}
li:nth-of-type(3) a:hover:before {
   background-color: green;
}
.unimportant {
   background-color: #fff;
   margin: 10%;
}


      </style> 
 </head> 
 <body> 
  <div> 
   <ul> 
    <li> <a href="">link 1</a> </li> 
    <li> <a href="">link 2</a> </li> 
    <li> <a href="">link 3</a> </li> 
   </ul> 
  </div> 
  <div class="unimportant">
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 
  </div>  
 </body>
</html>

Related Tutorials