Hover a div with position absolute - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Hover

Description

Hover a div with position absolute

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   www .j  a  v  a 2 s .  co m-->
   padding:0;
   margin:0;
}

body {
   background:Chartreuse;
   font-family:helvetica;
   font-weight:bold;
}

.news {
   position:relative;
   left:51%;
   margin-left:-301px;
   margin-top:51px;
   width:601px;
   height:301px;
   border-top:4px solid yellow;
   overflow:hidden;
}

.news img {
   cursor:pointer;
}

.text {
   position:absolute;
   top:86%;
   transition:all 0.4s ease;
}

.text h2 {
   margin-bottom:21px;
   text-align:center;
}

.text p {
   margin-left:11px;
   margin-right:11px;
   font-weight:normal;
}

.news:hover .text {
   top:66%;
}

span {
   position:absolute;
   top:0;
   background:blue;
   color:pink;
   padding:4px;
}
</style> 
 </head> 
 <body> 
  <div class="news"> 
   <span>Lorem ipsu</span> 
   <img src="https://www.java2s.com/style/demo/Safari.png" height="300" , width="600"> 
   <div class="text"> 
    <h2>Lorem ipsum dolor sit</h2> 
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpat. Vestibulum tort</p> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials