treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Slider Transitions Only Work if CSS is Applied In-Line

  • I'm using the code from this tutorial :

    http://thecodeplayer.com/walkthrough/css3-image-slider-with-stylized-thumbnails

    For some reason the transition effects only work if the css is applied inline but I would prefer to keep the css in a stylesheet. Any ideas why the transitions aren't working when the css is called externally? I don't think there's an issue with how I have linked to the stylesheet?

      <!doctype html>
      <html>
      <head>
      <meta charset="utf-8">
    
      <link rel="stylesheet" type="text/css" href="slider.css" />
    
      </head>
    
  • link to site?

  • http://mbmitservices.co.uk/slider.htm

    The transition effects only work in Firefox and IE10 if I link to an external stylesheet but if you look at the demo in the original link :

    http://thecodeplayer.com/walkthrough/css3-image-slider-with-stylized-thumbnails

    They work in chrome and opera as well.

  • You forgot to add prefixes. (-webkit-transform, -moz-transform, -o-transform etc..) line 54 and 25.

  • That wasn't mentioned in the tutorial! Thanks working now :

      .slider>img{
      position: absolute;
      left: 0; top: 0;
      transition: all 0.5s;
      -webkit-transition: all 0.5s;
      -moz-transition: all 0.5s;
      -o-transition : all 0.5s;
      }
    
      .slider input[name='slide_switch'] ~ img {
      opacity: 0;
      transform: scale(1.1);
      -webkit-transform: scale(1.1);
      -moz-transform: scale(1.1);
      -o-transform : scale(1.1);
      }
    
      .slider input[name='slide_switch']:checked+label+img {
      opacity: 1;
      transform: scale(1);
      -webkit-transform: scale(1);
      -moz-transform: scale(1);
      -o-transform : scale(1);
      }
    
  • One final issue with the script is that on an actual mobile device (i.e. not resizing a browser window on a PC) the thumbnails do not change the main slider image and that goes for the original code from the codeplayer link. Any idea why?