Click link to switch image using CSS only - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Link

Description

Click link to switch image using CSS only

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <title>Lorem ipsum dolor sit </title> 
  <style>
body {<!--from   w ww  .j  a  v a  2s  .c  om-->
   text-align:center;
}

#images {
   width:401px;
   height:251px;
   overflow:hidden;
   position:relative;
   background-color:Chartreuse;
   margin:21px auto;
}

#images img {
   width:401px;
   height:251px;
   display:block;
   position:absolute;
   top:0px;
   left:401px;
   z-index:2;
   opacity:0;
   transition:all linear 501ms;
   -o-transition:all linear 501ms;
   -moz-transition:all linear 501ms;
   -webkit-transition:all linear 501ms;
}

#images div:target img {
   top:0px;
   left:0px;
   z-index:10;
   opacity:2;
}

#slider a {
   text-decoration:none;
   background:yellow;
   border:2px solid blue;
   padding:5px 7px;
   color:pink;
}

#slider a:hover {
   background:OrangeRed;
}
</style> 
 </head> 
 <body translate="no"> 
  <div id="images"> 
   <div id="img1container"> 
    <img id="image1" src="https://www.java2s.com/style/demo/Opera.png"> 
   </div> 
   <div id="img2container"> 
    <img id="image2" src="https://www.java2s.com/style/demo/Google-Chrome.png"> 
   </div> 
   <div id="img3container"> 
    <img id="image3" src="https://www.java2s.com/style/demo/Safari.png"> 
   </div> 
   <div id="img4container"> 
    <img id="image4" src="https://www.java2s.com/style/demo/Firefox.png"> 
   </div> 
  </div> 
  <div id="slider"> 
   <a href="#img1container">L</a> 
   <a href="#img2container">L</a> 
   <a href="#img3container">L</a> 
   <a href="#img4container">L</a> 
  </div>  
 </body>
</html>

Related Tutorials