Before/After Image Slider Comparison (HTML, CSS, and JavaScript)

Before/After Image Slider Comparison (HTML, CSS, and JavaScript)

Coding in Public

2 года назад

19,763 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

SeppyDawg
SeppyDawg - 21.10.2023 18:13

Thank you!! Is it possible to add a code to track your mouse movement on hover?

Ответить
Jonathan Shannon
Jonathan Shannon - 15.10.2023 00:42

Great video, I do have a question though. I'm building a business website that requires me to show before and after pics of jobs I've done, I've added four sliders to my page but I'm only able to use the slider on the first image, the other three can't be moved from left to right. I've tried adding a class to each individual slider and updated the JScript but nothing seems to work. Any help on this would be much appreciated.

Ответить
Oscar José López Lucero
Oscar José López Lucero - 13.10.2023 20:26

Thanks man, u really helpful

Ответить
Ömer Faruk BORAN
Ömer Faruk BORAN - 20.09.2023 21:05

You are the man!

Ответить
somedoga
somedoga - 06.09.2023 16:08

see code below for working with multiple sliders
````
const els = document.querySelectorAll(".container")

els.forEach(el => {
for (let i = 0; i < el.childNodes.length; i++) {
if (el.childNodes[i].className === "slider") {
let j = el.childNodes[i];
j.addEventListener('input', (e) => {
el.style.setProperty('--position', `${e.target.value}%`);
})
}
}
})

const container = document.querySelector('.container');
document.querySelector('.slider')
````

Ответить
Noel Wiggins
Noel Wiggins - 15.07.2023 21:12

This is so fantastic. Exactly what I am looking to do. My only challenge is that I would love to have the images go full screen, both height and width. Would this be an easy fix?

Ответить
Yousef Miri
Yousef Miri - 12.07.2023 23:07

I just have one question, I need to make the image size to be like the container size . When I add my images they was to big and I didn’t know what to do . Thanks for your time !

Ответить
Arasy Design
Arasy Design - 27.06.2023 13:06

great job brother. but may i ask something, i want put 2 or more this image comparison on one page but it doesnt work, only the first one work, can u help me how to make more than one image comparison on one page? thank GBU

Ответить
Vitali Golev
Vitali Golev - 21.06.2023 15:35

Thank you for this, fantastic! I was doing it quickly, and it wouldn't work, then, of course, in js I found that I used normal single quote marks instead of the back ones. I works like magic :)

Ответить
Juan Moncada
Juan Moncada - 18.06.2023 01:38

amazing, thanks

Ответить
FoleysWorld
FoleysWorld - 13.06.2023 13:03

I learned so much in this video! thxs

Ответить
Mohammad Ahsan
Mohammad Ahsan - 12.06.2023 19:20

How can i add before / after text. Can you help me please?

Ответить
Mr.Everything
Mr.Everything - 09.06.2023 12:09

How Can I import images option instead of adding images every time?

Ответить
Eneri Niets
Eneri Niets - 21.05.2023 00:05

Oh wow, this video is amazing! How can I use it in my Shopify Shop? Any ideas? Thank´s a lot

Ответить
Local Creative
Local Creative - 05.05.2023 01:09

Thank you SO much! I was able to customize this for my website perfectly.

Ответить
MIAAD
MIAAD - 26.03.2023 16:31

thanks man the way you are explaining things is very simple and great !

Ответить
GARY VISION MUSIC CHANNEL
GARY VISION MUSIC CHANNEL - 26.03.2023 13:37

Hi bro ! It was a very interested video and the code works very well. Except that, my before image doesn't act like it should do. My before image's container is actually the space between the left border of the whole container and the slider's vertical bar. So each time I'm sliding, my before image's width is changing, making an unexpected zoom effect. Do you know how to fix it please ?

Ответить
Nitesh Raut
Nitesh Raut - 09.03.2023 11:07

how can we do vertical ?

Ответить
Etkoşko
Etkoşko - 06.02.2023 23:57

hey bro ı made perfectly but there is only one problem . the before image having a sharpness i dont know why . my images same resulotion but on the left image having an sharpness or kinda filter . how can i solve it, please help??

Ответить
CJ Lister
CJ Lister - 01.02.2023 19:35

So close but so far. I can get as far as having the images over lap and add the slider. But I cant move it. Its just like a static image I assume that the javascirpt isnt working, but I have no idea why.

Ответить
Byron F
Byron F - 24.01.2023 07:43

Love the video, just wondering what editor you are using?

Ответить
Katarzyna Śpikowska
Katarzyna Śpikowska - 24.12.2022 05:51

Hi, this is a great video! Thanks a lot :) Would you be able to code it on REACT?

Ответить
Abdallah Mahmoud
Abdallah Mahmoud - 16.12.2022 17:03

Perfect thank you

Ответить
Chan
Chan - 09.12.2022 12:11

will this work with a squarespace website?

Ответить
gronko
gronko - 26.11.2022 10:22

could this be done with videos?

Ответить
Niccole
Niccole - 23.11.2022 00:00

Thank you so much for the video-Do you have any videos explaining how to turn this all into HTML? I am a complete beginner to code and for my website it will only let me put in the HTML part. I found websites that explain it but I don't understand what any of it means ':)

Ответить
Samuel Kühne
Samuel Kühne - 23.10.2022 21:02

Hey I tried adding this code to my website with an iframe but the Iframe doesnt load on iphones or on safari do you know a fix for this I would really apreciate a response

Ответить
Adnan Niazi
Adnan Niazi - 29.09.2022 11:46

What if we want to change some content based on the after before images like when its after the text will be different and when its before the other div will show?

Ответить
Muhammad Ukasha
Muhammad Ukasha - 27.09.2022 11:20

What if you have multple image sliders? The code doesn't work if there are more than one sliders. :(

Ответить
Artemisa
Artemisa - 24.08.2022 00:22

Can someone help me work this out on angular, please? 🙏

Ответить
Arup De
Arup De - 08.06.2022 09:07

be regular .

Ответить
MANIKDENIS
MANIKDENIS - 06.06.2022 11:24

Absolutely amazing! It's a very creative and smart idea to use an input with the range type here. It was very interesting and informative, thank you, Chris!

Ответить
streamx2
streamx2 - 04.06.2022 00:12

Can I please ask that you try to start your projects with empty files. The is the reason behind the most successful coding channels like Traversy Media, NetNinja and even Wes Bos courses. It puts people off when you already have multiple files open and distracts from the tutorial. This tutorial was perfect because a person can follow along from the start.

Ответить
Jimmy J.
Jimmy J. - 31.05.2022 23:54

Congratz Chris for this nice content as over and over 🙏 totally crazy and genius 👌

Ответить
MarshallSC1
MarshallSC1 - 31.05.2022 20:39

You did it, once again... Just can't stop with the amazement!
Jaw-dropping good!

Ответить
Lộc Dương
Lộc Dương - 31.05.2022 18:39

Thank you so much 😍😍

Ответить
mohamad.ybr
mohamad.ybr - 31.05.2022 17:50

This is very interesting! I have always wondered how such things were developed.

Ответить
Maneth
Maneth - 31.05.2022 16:20

Great content! btw what theme do you use? and The Icon Pack

Ответить
Robert McGovern
Robert McGovern - 31.05.2022 15:59

Dang you made that look so easy. Nicely explained and great to see the consideration for accessibility

Ответить
Levan Vekua
Levan Vekua - 31.05.2022 15:33

As always the best content ❤ thank you!

Ответить
Indranil Halder
Indranil Halder - 31.05.2022 15:11

Very helpful

Ответить
Bhakti Videos
Bhakti Videos - 31.05.2022 15:03

You are awesome
Lovely content

Ответить