Skip to content

Instantly share code, notes, and snippets.

@fidelisrafael
Created September 17, 2013 19:09
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fidelisrafael/6599214 to your computer and use it in GitHub Desktop.
Save fidelisrafael/6599214 to your computer and use it in GitHub Desktop.
Simple horizontal slideshow with pure CSS3 Demo : http://codepen.io/fidelisrafael/full/guHlc
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Simple Slideshow with pure CSS3</title>
<style>
/* Document style */
body * {
box-sizing : border-box;
}
header > * {
font-size:2em;
margin:0;
}
header {
margin-bottom: 2em;
text-align: center;
}
small {
font-size:0.9em;
}
body {
font-family: Lato, Calibri, Arial, sans-serif;
color:#ffffff;
background:#ffffff;
margin:0;
padding:0;
}
/* Links */
a {
color:#ffffff;
text-decoration: none;
}
a:hover {
color:#333333;
}
section {
overflow: auto;
padding:3em;
margin: 0 auto;
}
/* Simple slideshow (not resposive - yet) */
.slideshow-wrapper {
width:704px;
overflow:hidden;
margin: 0 auto;
}
.slideshow-wrapper ul {
margin:0;
padding:0;
width: 2840px; /* 710 * 4 */
-webkit-animation: slideshow 10s infinite;
-moz-animation: slideshow 10s infinite;
-o-animation: slideshow 10s infinite;
animation: slideshow 10s infinite;
}
.slides .slide-image {
width:700px;
display:inline-block;
margin:0;
padding:0;
}
.slides .slide-image img {
width: 100%;
}
/* Helper classes */
.bg-blue {
background: #0E83CD;
}
.heart {
color:red;
font-size: 1.4em;
}
.text-center {
text-align: center;
}
.transition-all {
-webkit-transition: all 1s;
-moz-transition: all 1s;
-o-transition: all 1s;
transition: all 1s;
}
/* Animation */
@-webkit-keyframes slideshow {
0% { margin-left: 0.5%; }
25% { margin-left: -100%; }
50% { margin-left: -200%; }
75% { margin-left: -300%; }
}
@-moz-keyframes slideshow {
0% { margin-left: 0.5%; }
25% { margin-left: -100%; }
50% { margin-left: -200%; }
75% { margin-left: -300%; }
}
@-o-keyframes slideshow {
0% { margin-left: 0.5%; }
25% { margin-left: -100%; }
50% { margin-left: -200%; }
75% { margin-left: -300%; }
}
@keyframes slideshow {
0% { margin-left: 0.5%; }
25% { margin-left: -100%; }
50% { margin-left: -200%; }
75% { margin-left: -300%; }
}
/* Media queries */
@media only screen and (max-width:768px) {
.slideshow-wrapper { width:404px; }
.slideshow-wrapper .slides .slide-image{ width:400px; }
section { padding:0.5em; }
}
@media only screen and (max-width:400px) {
.slideshow-wrapper { width:304px; }
.slideshow-wrapper .slides .slide-image { width:300px;}
}
</style>
</head>
<body>
<section class="bg-blue">
<article class="slideshow">
<header>
<h1>Simple slideshow with pure CSS3</h1>
<small>not responsive(yet)</small>
</header>
<div class="slideshow-wrapper">
<ul class="slides">
<li class="slide-image">
<img src="http://placehold.it/700x300/333/whitesmoke&text=Slide%20+%20n1" />
</li>
<li class="slide-image">
<img src="http://placehold.it/700x300/5954EB/333&text=Slide%20+%20n1&text=slide+n2" />
</li>
<li class="slide-image">
<img src="http://placehold.it/700x300/49B853/ffffff&text=Slide%20+%20n3" />
</li>
<li class="slide-image">
<img src="http://placehold.it/700x300/CF69CF/ffffff&text=Slide%20+%20n4" />
</li>
</ul>
</div>
<footer>
<p class='text-center'><br />
Made with love <span class='heart'>&hearts;</span> by
<a href="http://defidelis.herokuapp.com" title="Rafael Fidelis : Blog" class='transition-all' target="_blank">Rafael Fidelis</a>
</p>
</footer>
</article>
</section>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment