arijulianto

Image Title Hovered Using CSS

May 12th, 2014
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 0.79 KB | None | 0 0
  1. <style type="text/css">
  2.   a.hovertext {
  3.     position: relative;
  4.     width: 500px;
  5.     text-decoration: none !important;
  6.     text-align: center;
  7.   }
  8.   a.hovertext:after {
  9.     content: attr(data-title);
  10.     position: absolute;
  11.     left: 0;
  12.     bottom: 0;
  13.     padding: 0.5em 20px;
  14.     width: 460px;
  15.     background: rgba(0,0,0,0.8);
  16.     text-decoration: none !important;
  17.     color: #fff;
  18.     opacity: 0;
  19.     -webkit-transition: 0.5s;
  20.     -moz-transition: 0.5s;
  21.     -o-transition: 0.5s;
  22.     -ms-transition: 0.5s;
  23.   }
  24.   a.hovertext:hover:after, a.hovertext:focus:after {
  25.     opacity: 1.0;
  26.   }
  27.  
  28. </style>
  29.  
  30. <p><a class="hovertext" data-title="The title attribute of the link appears over the image on hover"><img src="photo/000022.jpg" width="500" height="309" border="0" alt=""></a></p>
Advertisement
Add Comment
Please, Sign In to add comment