Click here to Skip to main content
15,445,997 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I haven't made the code from the bottom myself. I leant it from http://cssdeck.com/labs/css3-image-slider[^]

But I've changed the code to match what I wanted. The only thing I can't get it to do, is to automatically change slide, and when it's reached the last slide, I want it to go in a loop and slide to the first image again.
I know sliders are probably easier in bootstrap or even with js, but I'd really like to be able to manage these problems in only HTML/CSS.
Here's my JSFiddle, though no JS has been used: http://jsfiddle.net/jaxttde6/[^]


HTML:
XML
<div id="slideshow-wrap">
           <input type="radio" id="button-1" name="controls" checked="checked" />
           <label for="button-1"></label>
           <input type="radio" id="button-2" name="controls" />
           <label for="button-2"></label>
           <input type="radio" id="button-3" name="controls" />
           <label for="button-3"></label>
           <input type="radio" id="button-4" name="controls" />
           <label for="button-4"></label>
           <input type="radio" id="button-5" name="controls" />
           <label for="button-5"></label>
           <div id="slideshow-inner">
               <ul>
                   <li id="slide1">
                       <img src="http://i59.tinypic.com/vxlzef.jpg" />
                   </li>
                   <li id="slide2">
                       <img src="http://i62.tinypic.com/svgirp.jpg" />
                   </li>
                   <li id="slide3">
                       <img src="http://i59.tinypic.com/311pe1d.jpg" />
                   </li>
                   <li id="slide4">
                       <img src="http://i58.tinypic.com/10i9imd.jpg" />
                   </li>
                   <li id="slide5">
                       <img src="http://i58.tinypic.com/s1qm1d.jpg" />
                   </li>
               </ul>
           </div>
       </div>


CSS:
#slideshow-wrap {
    display: block;
    height: 300px;
    min-width: 260px;
    max-width: 960px;
    margin: auto;
    margin-top: 45px;
    position: relative;
}

#slideshow-inner {
    width: 100%;
    height: 100%;
    background-color: rgb(0,0,0);
    overflow: hidden;
    position: relative;
}

#slideshow-inner>ul {
    list-style: none;
    height: 100%;
    width: 500%;
    overflow: hidden;
    position: relative;
    left: 0px;
    -webkit-transition: left .8s cubic-bezier(0.77, 0, 0.175, 1);
    -moz-transition: left .8s cubic-bezier(0.77, 0, 0.175, 1);
    -o-transition: left .8s cubic-bezier(0.77, 0, 0.175, 1);
    transition: left .8s cubic-bezier(0.77, 0, 0.175, 1);
}

#slideshow-inner>ul>li {
    width: 20%;
    height: 300px;
    float: left;
    position: relative;
}

#slideshow-inner>ul>li>img {
    margin: auto;
    height: 100%;
}

#slideshow-wrap input[type=radio] {
    position: absolute;
    left: 50%;
    bottom: 15px;
    z-index: 100;
    visibility: hidden;
}

#slideshow-wrap label:not(.arrows):not(.show-description-label) {
    position: absolute;
    left: 50%;
    bottom: 20px;
    z-index: 100;
    width: 12px;
    height: 12px;
    background-color: #feffe1;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    border-radius: 50%;
    cursor: pointer;
    -webkit-transition: background-color .2s;
    -moz-transition: background-color .2s;
    -o-transition: background-color .2s;
    transition: background-color .2s;
}

#slideshow-wrap label:not(.arrows):active { bottom: 20px }

#slideshow-wrap input[type=radio]#button-1:checked~label[for=button-1] { background-color: rgba(100,100,100,1) }

#slideshow-wrap input[type=radio]#button-2:checked~label[for=button-2] { background-color: rgba(100,100,100,1) }

#slideshow-wrap input[type=radio]#button-3:checked~label[for=button-3] { background-color: rgba(100,100,100,1) }

#slideshow-wrap input[type=radio]#button-4:checked~label[for=button-4] { background-color: rgba(100,100,100,1) }

#slideshow-wrap input[type=radio]#button-5:checked~label[for=button-5] { background-color: rgba(100,100,100,1) }

#slideshow-wrap label[for=button-1] { margin-left: -36px }

#slideshow-wrap label[for=button-2] { margin-left: -18px }

#slideshow-wrap label[for=button-4] { margin-left: 18px }

#slideshow-wrap label[for=button-5] { margin-left: 36px }

#slideshow-wrap input[type=radio]#button-1:checked~#slideshow-inner>ul { left: 0 }

#slideshow-wrap input[type=radio]#button-2:checked~#slideshow-inner>ul { left: -100% }

#slideshow-wrap input[type=radio]#button-3:checked~#slideshow-inner>ul { left: -200% }

#slideshow-wrap input[type=radio]#button-4:checked~#slideshow-inner>ul { left: -300% }

#slideshow-wrap input[type=radio]#button-5:checked~#slideshow-inner>ul { left: -400% }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900