Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Image Slider - New Nillervision Tutorial

Featured Replies

Hello everyone.

I've uploaded a new tutorial this morning about how to create a responsive image slider without scripting, The slider uses CSS keyframes.

I would love to hear your feedback. Thank you :)

Edited by Nillervision

  • Author

Thanks Niller.

You're welcome Precise Formwork :) Don't hesitate to ask if you have any questions or comments

Edited by Nillervision

Nice work, You may want to consider doing a follow up video where you work on improving the performance - i.e. animating transforms as opposed to left/right properties, putting the entire slider on it's own composite layer. Paul Irish covers this kind of stuff in great detail and I think would make a nice follow up (Keeping two separate vids so as to not overload newbs with information :) )

 

I tend to think with these things you:

1. get it working

2. refactor (Both code readability and actual performance)

Edited by rbrtsmith

  • Author

Nice work, You may want to consider doing a follow up video where you work on improving the performance - i.e. animating transforms as opposed to left/right properties, putting the entire slider on it's own composite layer. Paul Irish covers this kind of stuff in great detail and I think would make a nice follow up (Keeping two separate vids so as to not overload newbs with information :) )

 

I tend to think with these things you:

1. get it working

2. refactor (Both code readability and actual performance)

Thanks for the useful feedback Robert. It is much appreciated. I was planing to do a follow up with a slider that responds to clicks/ touch. So I will probably be looking in to your suggestions for optimized performance as well :)

I agree that it should be in a new video anyway. I think I already squeeze to much information into each video. Because I would like both to explain things in depth for beginners and still have enough substance for more advanced viewers :)

 

Really awesome....Looks like it is an alternate to a heavy Video

Thank you prateeksha :)

Edited by Nillervision

Nice idea, but I would recommend against using an actual <img> to make the slider responsive.

 

Instead there's a neat trick where, if you set each slide to position: absolute and give the wrapper a :before/ :after pseudo element with a padding-bottom/ padding-top whose value is a percentage which resembles the same aspect ratio of the slider images, it scales in exactly the same way. It's a little fiddly getting the right percentage, but it's worth it.

 

You could even go further and add a min-height to the slider so that images don't appear to 'letterbox' when the browser's width is rather small. This would require centering (and therefore cropping) the slides, however, so would require careful consideration in regards to art direction, etc.

 

I realise that's a mouthful, so I whipped up a little CodePen example and you can see it in action here.

 

Also, I was always under the assumption that it was bad practise to use background images for stuff that could otherwise be considered content.

Edited by jakdothtml

  • Author

Nice idea, but I would recommend against using an actual <img> to make the slider responsive.

 

Instead there's a neat trick where, if you set each slide to position: absolute and give the wrapper a :before/ :after pseudo element with a padding-bottom/ padding-top whose value is a percentage which resembles the same aspect ratio of the slider images, it scales in exactly the same way. It's a little fiddly getting the right percentage, but it's worth it.

 

You could even go further and add a min-height to the slider so that images don't appear to 'letterbox' when the browser's width is rather small. This would require centering (and therefore cropping) the slides, however, so would require careful consideration in regards to art direction, etc.

 

I realise that's a mouthful, so I whipped up a little CodePen example and you can see it in action here.

 

Also, I was always under the assumption that it was bad practise to use background images for stuff that could otherwise be considered content.

Thanks for your inputs Jack. Some very good points. I used the placeholder image to keep things simple and I actually think it is OK (in terms of performance) because the image will be loaded anyway. But it should probably have an empty alt attribute since it is hidden. Of cause if you want the images indexed by google you would have to use img tags. The reason I'm using background images instead of img elements is because of the overlay texture. When using background elements with the value cover the images will always stretch to cover exactly the same area as the relative parent div even if the aspect ratio is a bit off. When using img tags (which was my first idea) I noticed that sometimes the overlay texture takes up a little more space than the images even when all padding was removed from the parent. If you are not using an overlay img tags works fine though.

EDIT: Brilliant suggestion with the min-height. I will add an annotation to the video with that.

Edited by Nillervision

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.