Skip to content

Instantly share code, notes, and snippets.

@alasomlira
Created December 17, 2019 13:56
Show Gist options
  • Save alasomlira/c09ea292275548facfb75fab9573134b to your computer and use it in GitHub Desktop.
Save alasomlira/c09ea292275548facfb75fab9573134b to your computer and use it in GitHub Desktop.
#1577 - Image Hover
<figure class="snip1577">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample99.jpg" alt="sample99" />
<figcaption>
<h3>Bodrum Salvador</h3>
<h4>Luxery</h4>
</figcaption>
<a href="#"></a>
</figure>
<figure class="snip1577 hover"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample109.jpg" alt="sample109" />
<figcaption>
<h3>Jason Response</h3>
<h4>Classic</h4>
</figcaption>
<a href="#"></a>
</figure>
<figure class="snip1577"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample117.jpg" alt="sample117" />
<figcaption>
<h3>Piff Jenkins</h3>
<h4>Vintage</h4>
</figcaption>
<a href="#"></a>
</figure>
/* Demo purposes only */
$(".hover").mouseleave(
function() {
$(this).removeClass("hover");
}
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
@import url(https://fonts.googleapis.com/css?family=Montserrat:200);
.snip1577 {
font-family: 'Montserrat', Arial, sans-serif;
position: relative;
display: inline-block;
overflow: hidden;
margin: 10px;
min-width: 230px;
max-width: 315px;
width: 100%;
color: #fff;
text-align: left;
font-size: 16px;
background: #000;
}
.snip1577 *,
.snip1577:before,
.snip1577:after {
-webkit-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.snip1577 img {
max-width: 100%;
backface-visibility: hidden;
vertical-align: top;
}
.snip1577:before,
.snip1577:after {
position: absolute;
top: 20px;
right: 20px;
content: '';
background-color: #fff;
z-index: 1;
opacity: 0;
}
.snip1577:before {
width: 0;
height: 1px;
}
.snip1577:after {
height: 0;
width: 1px;
}
.snip1577 figcaption {
position: absolute;
left: 0;
bottom: 0;
padding: 15px 20px;
}
.snip1577 h3,
.snip1577 h4 {
margin: 0;
font-size: 1.1em;
font-weight: normal;
opacity: 0;
}
.snip1577 h4 {
font-size: .8em;
text-transform: uppercase;
}
.snip1577 a {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1;
}
.snip1577:hover img,
.snip1577.hover img {
zoom: 1;
filter: alpha(opacity=20);
-webkit-opacity: 0.2;
opacity: 0.2;
}
.snip1577:hover:before,
.snip1577.hover:before,
.snip1577:hover:after,
.snip1577.hover:after {
opacity: 1;
-webkit-transition-delay: 0.25s;
transition-delay: 0.25s;
}
.snip1577:hover:before,
.snip1577.hover:before {
width: 40px;
}
.snip1577:hover:after,
.snip1577.hover:after {
height: 40px;
}
.snip1577:hover h3,
.snip1577.hover h3,
.snip1577:hover h4,
.snip1577.hover h4 {
opacity: 1;
}
.snip1577:hover h3,
.snip1577.hover h3 {
-webkit-transition-delay: 0.3s;
transition-delay: 0.3s;
}
.snip1577:hover h4,
.snip1577.hover h4 {
-webkit-transition-delay: 0.35s;
transition-delay: 0.35s;
}
<link href="https://www.littlesnippets.net/css/codepen-result.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment