Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jensgro/a41f0718b1c3a1193d61837e2c227855 to your computer and use it in GitHub Desktop.
Save jensgro/a41f0718b1c3a1193d61837e2c227855 to your computer and use it in GitHub Desktop.
Bilder mit animierten Captions
<div id="mainwrapper">
<!-- Image Caption 1 -->
<div id="box-1" class="box">
<img id="image-1" src="http://lorempixel.com/200/200/people"/>
<span class="caption simple-caption">
<p>Simple Caption</p>
</span>
</div>
<!-- Image Caption 2 -->
<div id="box-2" class="box">
<img id="image-2" src="http://lorempixel.com/200/200/animals"/>
<span class="caption full-caption">
<h3>Full Caption</h3>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
</span>
</div>
<!-- Image Caption 3 -->
<div id="box-3" class="box">
<img id="image-3" src="http://lorempixel.com/200/200/city"/>
<span class="caption fade-caption">
<h3>Fade Caption</h3>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
</span>
</div>
<!-- Image Caption 4 -->
<div id="box-4" class="box">
<img id="image-4" src="http://lorempixel.com/200/200"/>
<span class="caption slide-caption">
<h3>Slide Caption</h3>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
</span>
</div>
<!-- Image Caption 5 -->
<div id="box-5" class="box">
<div class="rotate">
<img id="image-5" src="http://placekitten.com/200/200"/>
<span class="caption rotate-caption">
<h3>This is rotate caption</h3>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
</span>
</div>
</div>
<!-- Image Caption 6 -->
<div id="box-6" class="box">
<img id="image-6" src="http://unsplash.it/400/300"/>
<span class="caption scale-caption">
<h3>Scale Caption</h3>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
</span>
</div>
</div>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
html {
font-size: 16px;
}
#mainwrapper {
font: 1rem normal Verdana, sans-serif;
height: auto;
margin: 80px auto 0 auto;
text-align: center;
width: 660px;
}
/* Image Box Style */
#mainwrapper .box {
border: 5px solid #fff;
cursor: pointer;
height: 182px;
float: left;
margin: 5px;
position: relative;
overflow: hidden;
width: 200px;
box-shadow: 1px 1px 1px 1px #ccc;
}
#mainwrapper .box img {
position: absolute;
left: 0;
transition: all 300ms ease-out;
}
/* Caption Common Style */
#mainwrapper .box .caption {
background-color: rgba(0,0,0,0.8);
position: absolute;
color: #fff;
z-index: 100;
transition: all 300ms ease-out;
left: 0;
}
/** Caption 1: Simple **/
#mainwrapper .box .simple-caption {
height: 50px;
width: 200px;
display: block;
bottom: -50px;
line-height: 25px;
text-align: center;
}
/** Caption 2: Full Width & Height **/
#mainwrapper .box .full-caption {
width: 170px;
height: 170px;
top: -200px;
text-align: left;
padding: 15px;
}
/** Caption 3: Fade **/
#mainwrapper .box .fade-caption, #mainwrapper .box .scale-caption {
opacity: 0;
width: 170px;
height: 170px;
text-align: left;
padding: 15px;
}
/** Caption 4: Slide **/
#mainwrapper .box .slide-caption {
width: 170px;
height: 170px;
text-align: left;
padding: 15px;
left: 200px;
}
/** Caption 5: Rotate **/
#mainwrapper #box-5.box .rotate-caption {
width: 170px;
height: 170px;
text-align: left;
padding: 15px;
top: 200px;
transform: rotate(-180deg);
}
#mainwrapper .box .rotate {
width: 200px;
height: 400px;
transition: all 300ms ease-out;
}
/** Caption 6: Scale **/
#mainwrapper .box .scale-caption h3, #mainwrapper .box .scale-caption p {
position: relative;
left: -200px;
width: 170px;
transition: all 300ms ease-out;
}
#mainwrapper .box .scale-caption h3 {
transition-delay: 300ms;
}
#mainwrapper .box .scale-caption p {
transition-delay: 500ms;
}
/** Simple Caption :hover Behaviour **/
#mainwrapper .box:hover .simple-caption {
opacity: 1;
transform: translateY(-100%);
}
/** Full Caption :hover Behaviour **/
#mainwrapper .box:hover .full-caption {
opacity: 1;
transform: translateY(100%);
}
/** Fade Caption :hover Behaviour **/
#mainwrapper .box:hover .fade-caption, #mainwrapper .box:hover .scale-caption {
opacity: 1;
}
/** Slide Caption :hover Behaviour **/
#mainwrapper .box:hover .slide-caption {
background-color: rgba(0,0,0,1) !important;
opacity: 1;
transform: translateX(-100%);
}
#mainwrapper .box:hover img#image-4 {
transform: translateX(-100%);
opacity: 1;
}
/** Rotate Caption :hover Behaviour **/
#mainwrapper .box:hover .rotate {
background-color: rgba(0,0,0,1) !important;
transform: rotate(-180deg);
}
/** Scale Caption :hover Behaviour **/
#mainwrapper .box:hover #image-6 {
transform: scale(1.4);
}
#mainwrapper .box:hover .scale-caption h3, #mainwrapper .box:hover .scale-caption p {
transform: translateX(200px);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment