HTML5 Zone is brought to you in partnership with:

I was born in 1981 in one little city. Since I was 10y/o I programmed in different languages. My first languages were basic, then C++/MFC, after .Net (C#, VB.Net, J#, ASP.Net), XSL+XML processing). In the last 5 years I worked with web languages (HTML, CSS, PHP, SQL, XML, XSL, JavaScript). After university I worked in several different companies, eventually becoming a blogger. This is my hobby too. Andrey is a DZone MVB and is not an employee of DZone and has posted 111 posts at DZone. You can read more from them at their website. View Full User Profile

CSS3 Animated Photo Slider

  • submit to reddit
Today I have prepared a new great CSS3 demonstration. This is a 3D slideshow where I have used WebKit CSS 3D transforms. In the demo you will see a free-floating 3D object with photos. But – you have to use Chrome or Safari to see all these delights.

Live Demo

download result

Ok, download the example files and let's start coding !

Step 1. HTML

First, let's create the main HTML markup. As you can see – the structure is quite minimal as usual and contains only several DIV and IMG elements.

<!DOCTYPE html>
<html lang="en" >
        <meta charset="utf-8" />
        <title>CSS3 Animated Photo Slider | Script Tutorials</title>
        <link href="css/layout.css" rel="stylesheet" type="text/css" />
        <link href="css/slider.css" rel="stylesheet" type="text/css" />
            <h2>CSS3 Animated Photo Slider</h2>
            <a href="" class="stuts">Back to original tutorial on <span>Script Tutorials</span></a>

        <div class="slider">
            <div class="x_rot">
                <div class="y_rot">
                    <div id="i1">
                        <img src="images/1.jpg" />
                    <div id="i2">
                        <img src="images/2.jpg" />
                    <div id="i3">
                        <img src="images/3.jpg" />
                    <div id="i4">
                        <img src="images/4.jpg" />
                    <div id="i5">
                        <img src="images/5.jpg" />
                    <div id="i6">
                        <img src="images/6.jpg" />

Step 2. CSS

Now, here are the CSS rules that will transform our markup into a great animated photo slider. I have already commented the CSS below, so you can see the major parts of this file.

/* Animations with keyframes */
@-webkit-keyframes x_rot {
    0%    { -webkit-transform: rotateX(-30deg); }
    50%   { -webkit-transform: rotateX(30deg); }
    100%  { -webkit-transform: rotateX(-30deg); }
@-webkit-keyframes y_rot {
    0%    { -webkit-transform: rotateY(0deg); }
    50%   { -webkit-transform: rotateY(180deg); }
    100%  { -webkit-transform: rotateY(360deg); }

/* main styles */
.slider {
    margin: 250px auto;

    -webkit-perspective: 1000; /* setup perspective to parent */
.x_rot {
    -webkit-transform-style: preserve-3d;
    -webkit-animation-name: x_rot; /* setup custom animations */
    -webkit-animation-duration: 6s;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-timing-function: ease;
.y_rot {
    -webkit-transform-style: preserve-3d;
    -webkit-animation-name: y_rot; /* setup custom animations */
    -webkit-animation-duration: 10s;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-timing-function: linear;
.y_rot div {
    color: rgba(0,0,0,0.9);
    height: 235px;
    left: 300px;
    opacity: 0.8;
    position: absolute;
    width: 235px;

    -webkit-border-radius: 15px;
    -webkit-transition: .3s;
.y_rot div#i1 {
    -webkit-transform: rotateY(0deg) translateZ(200px);
.y_rot div#i2 {
    -webkit-transform: rotateY(60deg) translateZ(200px);
.y_rot div#i3 {
    -webkit-transform: rotateY(120deg) translateZ(200px);
.y_rot div#i4 {
    -webkit-transform: rotateY(180deg) translateZ(200px);
.y_rot div#i5 {
    -webkit-transform: rotateY(240deg) translateZ(200px);
.y_rot div#i6 {
    -webkit-transform: rotateY(300deg) translateZ(200px);
.y_rot div img {

    -webkit-border-radius: 15px;
    -webkit-transition: .3s;

/* onhover effect */
.y_rot div#i1:hover,
.y_rot div#i2:hover,
.y_rot div#i3:hover,
.y_rot div#i4:hover,
.y_rot div#i5:hover,
.y_rot div#i6:hover {
    opacity: 1;
.y_rot div#i1:hover img,
.y_rot div#i2:hover img,
.y_rot div#i3:hover img,
.y_rot div#i4:hover img,
.y_rot div#i5:hover img,
.y_rot div#i6:hover  img{

/* pause main animation onhover */
.x_rot:hover {
    -webkit-animation-play-state: paused;
.y_rot:hover {
    -webkit-animation-play-state: paused;

Today, I omit styles of page layout (layout.css). This is not important right now. File will available in package.

Live Demo

download result


Today we have made another great CSS3 photo slideshow. Just one note, as above: we have used CSS3 animation with 3D Transforms – and this is supported only in Chrome and Safari browsers. For more information – look here. Let's hope that coming versions of FF will support this too. Happy Holidays, and, you are welcome to leave your comments here!



Published at DZone with permission of Andrey Prikaznov, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)