Skip to content

Instantly share code, notes, and snippets.

Created August 12, 2011 20:03
Show Gist options
  • Save whistler/1142872 to your computer and use it in GitHub Desktop.
Save whistler/1142872 to your computer and use it in GitHub Desktop.
Create Onhover Image Caption Using CSS
/* parent div and hover properties */
.imgteaser {
margin: 0;
overflow: hidden;
float: left;
position: relative;
.imgteaser a {
text-decoration: none;
float: left;
.imgteaser a:hover {
cursor: pointer;
/* image border */
.imgteaser a img {
float: left;
margin: 0;
border: none;
padding: 10px;
background: #fff;
border: 1px solid #ddd;
/* learn more */
.imgteaser a .more {
position: absolute;
right: 20px;
bottom: 20px;
font-size: 1.2em;
color: #fff;
background: #000;
padding: 5px 10px;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=65)"; /*--IE 8 Transparency--*/
.imgteaser a:hover .desc{
display: block;
font-size: 1.2em;
padding: 10px 0;
background: #111;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=75)"; /*--IE 8 Transparency--*/
color: #fff;
position: absolute;
bottom: 11px;
left: 11px;
padding: 10px;
margin: 0;
width: 566px;
border-top: 1px solid #999;
.imgteaser a:hover .desc strong {
display: block;
margin-bottom: 5px;
/* hide learn more */
.imgteaser a .desc { display: none; }
.imgteaser a:hover .more { visibility: hidden;}
<div class="imgteaser">
<a href="#">
<img src="Daim1.jpg" alt="Daim Graffiti" />
<span class="more">&raquo; Learn More</span>
<span class="desc">
<strong>DAIM 2002</strong>
Blandit turpis patria euismod at iaceo appellatio, demoveo esse. Tation utrum utrum abigo demoveo immitto aliquam sino aliquip.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment