Platinum Partner
css,html5,html & xhtml

CSS3 Animated Photo Slider

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.

index.html

<!DOCTYPE html>
<html lang="en" >
    <head>
        <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" />
    </head>
    <body>
        <header>
            <h2>CSS3 Animated Photo Slider</h2>
            <a href="http://www.script-tutorials.com/css3-animated-photo-slider/" class="stuts">Back to original tutorial on <span>Script Tutorials</span></a>
        </header>

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

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.

css/slider.css

/* 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 {
    height:235px;
    width:235px;

    -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{
    height:335px;
    width:335px;
    margin-left:-50px;
    margin-top:-50px;
}

/* 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


Conclusion

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!

 

Source: http://www.script-tutorials.com/css3-animated-photo-slider/

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}