Demo: Creating A Pure CSS Content Slider

Here's the CSS for a pure CSS content slider. You can see the slider in action on our home page.



.slider-container {
    width: 1000px;
    position: absolute;
    left: 0;
    top: 120px;
    height: 236px;
    padding: 10px 0px;
    overflow: hidden;
    margin: 10px auto;
}
.slider-box {
    width: 300px;
    height: 220px;
    margin: 0 0px 0 0px;
    padding: 4px 5px;
    position: absolute;
    border: 4px solid #fff;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    border-radius: 3px;
    -webkit-box-shadow: 0 0 4px rgba(0,0,0,0.2);
    -moz-box-shadow: 0 0 4px rgba(0,0,0,0.2);
    box-shadow: 0 0 4px rgba(0,0,0,0.2);
    background-color: #fff;
    background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,0)), to(rgba(0,0,0,0.15)));
    display: block;
    overflow: hidden;
    -webkit-transition: border-color 200ms ease-out;
    -moz-transition: border-color 200ms ease-out;
}
.slider-box:hover {
    -webkit-box-shadow: 0 0 8px rgba(0,0,0,0.4);
    -moz-box-shadow: 0 0 8px rgba(0,0,0,0.4);
    box-shadow: 0 0 8px rgba(0,0,0,0.4);
    border: 4px solid #37abe5;
}
.slider-box h3 a {
    position: relative;
    height: 36px;
    width: 300px;
    display: block;
    margin-top: -66px;
    padding: 13px 2px 0px 8px;
    margin-left: -5px;
    color: #424242;
    font-family: 'Qlassik', Helvetica;
    font-size: 26px;
    line-height: 24px;
    z-index: 90;
    bottom: 6px;
    background-color: yellow;
    background-color: rgba(254,255,0,0.9);
    background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,0)), to(rgba(0,0,0,0.15)));
    -webkit-border-top-left-radius: 6px;
    -webkit-border-top-right-radius: 6px;
    -webkit-border-bottom-left-radius: 3px;
    -webkit-border-bottom-right-radius: 3px;
    -moz-border-radius-topleft: 6px;
    -moz-border-radius-topright: 6px;
    -moz-border-radius-bottomleft: 3px;
    -moz-border-radius-bottomright: 3px;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    border-bottom-left-radius: 3px;
    border-bottom-right-radius: 3px;
    -webkit-box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    -moz-box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
}
.slider-box h3 a:hover, .slider-box h3 a:focus {
    border: none;
    text-decoration: none;
}
.slider-box .image {
    position: relative;    
    height: 228px;
    width: 310px;
    margin: -5px 0 0 -5px;
    z-index: 10;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    border-radius: 3px;
}
 
@-webkit-keyframes slider {
0% {
    -webkit-transform: translate(0px, 0);
} 
45% {
    -webkit-transform: translate(0px, 0);
}
55% {
    -webkit-transform: translate(-1020px, 0);
}
100% {
    -webkit-transform: translate(-1020px, 0);
}
}
.slider-box {
    -webkit-animation-name: slider; 
    -webkit-animation-duration: 15s;
     -webkit-animation-direction: alternate;
    -webkit-animation-timing-function: ease-in-out;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-delay: 10s;
}
.slider-box.one {
    left: 0px;   
}.slider-box.two {
    left: 340px;
}.slider-box.three {
    left: 680px;
}.slider-box.four {
    left: 1020px;
}.slider-box.five {
    left: 1360px;
}.slider-box.six {
    left: 1700px;
}
 
.slider-box.one h3 a {
    background-color: #3198dd;
    color: #ebebeb;
    text-shadow: #1d6fa5 0 1px 0;
}
.slider-box.two h3 a {
    background-color: #87ee00;
}
.slider-box.five h3 a {
    background-color: #87ee00;
}
.slider-box.six h3 a {
    background-color: #3198dd;
    color: #ebebeb;
    text-shadow: #1d6fa5 0 1px 0;
}


Site design © BMC WebDesign, 2011. All rights reserved. All tutorials on this site are free for commerical use, subject to conditions outlined in the disclaimer.