Тёмный

Parallax effect | 2 different ways to add it with jQuery 

Kevin Powell
Подписаться 948 тыс.
Просмотров 89 тыс.
50% 1

Опубликовано:

 

25 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 204   
@KevinPowell
@KevinPowell 7 лет назад
The background scroll animation wasn't really 'generalized' like I had hoped it would be. Next time I should test things a bit more!!! But I have revised the code, so if you have multiple backgrounds that you'd like to use this effect on, this should work! codepen.io/kevinpowell/pen/YVOLGz
@rasel309
@rasel309 6 лет назад
Kevin Powell subscribed you keep this good work going.a question for you.do u have video on how you make this template?how toy have who we are border around thais text.I have a idea but need to know.yours.
@tokomeno9533
@tokomeno9533 6 лет назад
Kevin Powell good content keep doing and i think your channel will grow up fast, i found lot of usefull stuff in your chanel and what i like is videos are small i can learn something new in half hour when i have break or im in bus i can just pick phone and watch one of your videos. Thanks
@KevinPowell
@KevinPowell 6 лет назад
Thanks for the kind words Toko Meno! Glad you're enjoying my content 😁
@KevinPowell
@KevinPowell 6 лет назад
Super sorry for the really late reply rasel! It's probably too late, but this is the series where I built that page How to create a responsive website from scratch: ru-vid.com/group/PL4-IK0AVhVjOH5r4GAtlk1-tLUlEdiqXG
@annasognosia
@annasognosia Год назад
plenty of people post code that works and I'm grateful to them but Kevin actually succeeds in understanding what's going on and communicating it to boot.
@CaerelsJan
@CaerelsJan 5 лет назад
Amazing! I never would have guessed Parallax was THAT easy. Thanks Kevin for yet another great tutorial. (Okay I know this is from more than two years ago, but there's just so many great videos of you I have yet to watch)
@shibuya3937
@shibuya3937 5 лет назад
FINALLY, THE TUTORIAL I'VE BEEN LOOKING FOR. Thank you Kevin!
@dccreative275
@dccreative275 7 лет назад
I've been racking my brain and keyboard trying to implement this onto a site i'm building. Wish I would've watched this first! Would've saved me a lot of frustration and headaches. Great video!
@KevinPowell
@KevinPowell 7 лет назад
Awesome man, I'm really glad that this helped!
@KingKilleer96
@KingKilleer96 7 лет назад
great video man, i like how u are actually explaining what u are doing and not just writing the code... hope u never stop making awesome vids! Thanks
@KevinPowell
@KevinPowell 7 лет назад
Really happy that you like the videos mtg! I don't plan on stopping any time soon :D!
@tomikemppainen4228
@tomikemppainen4228 5 лет назад
Thank you for this video, I've been looking for responsive parallax effect for a long time now and now I've finally found a parallax effect that also works well on mobile devices!
@xox-marissa-xox
@xox-marissa-xox 7 лет назад
One of my friends is designing a website and picked a template specifically because it had parallax effects. This really make a site feel more modern and high-end. I was also a little confused about what "parallax" meant because to me it looked so similar to background-fixed so seeing the coding and comparison really helps explain it in a way I can understand :D
@KevinPowell
@KevinPowell 7 лет назад
Glad I could help clarify it a little. The one thing to watch out for is how it works on mobile. It can get a little janky and slow the site down.
@pratamaa.sumirat7274
@pratamaa.sumirat7274 6 лет назад
Thanks, Kevin! Just finished this series, adding another line of code which stops the parallax of the box if wScroll < 600, so if I scroll down a little bit more, the box just stay aligned and not going down anymore. I'll try to create my own version of this, then continuing your portfolio playlist, then your bootstrap playlist. Your channel is really awesome!
@KevinPowell
@KevinPowell 6 лет назад
That's probably a good idea for performance, no reason to keep moving it around it it's off page! Glad you're enjoying my videos!
@VaiGo
@VaiGo 6 лет назад
I am trying to understand Jquery for the past 2 weeks and because of you I understood it now. Thanks so much
@KevinPowell
@KevinPowell 6 лет назад
Glad that it helped VaiGo! I'm sure you were starting to get it already, you just needed that extra push to help things click :)
@droosoo
@droosoo 5 лет назад
the background-attachment is a life saver thank you!
@drewconroy5938
@drewconroy5938 6 лет назад
Kevin: Fantastic job! Its classy and not to flashy. Great balance of color and flows great:)
@KevinPowell
@KevinPowell 6 лет назад
Thanks so much!
@ConquerJS
@ConquerJS 7 лет назад
Awesome thanks for actually doing it! I'm at a stage where I rather use vanilla JS for everything so I might try to translate what you wrote to plain javascript. Thanks again! hopefully you have more in store for us!
@KevinPowell
@KevinPowell 7 лет назад
Let me know how it goes with the vanilla JS!
@thewetfly9207
@thewetfly9207 6 лет назад
let p = document.getElementsByClassName('parallax--bg')[0]; let b = document.getElementsByClassName('parallax--box')[0]; window.onscroll = function(){ let scrollY = window.scrollY; p.style.backgroundPosition = 'center ' + (scrollY*0.5) + 'px'; b.style.top = -5 + (scrollY*0.01) + 'em'; };
@ravenclaw2437
@ravenclaw2437 7 лет назад
If you wanna the box to goes up just put the - sign before the (wScroll)
@boosboop
@boosboop 6 лет назад
Super clear guide. Just what I needed! Thank you!
@KevinPowell
@KevinPowell 6 лет назад
No problem Carlos, glad you liked it :)
@frozendiary
@frozendiary 5 лет назад
The way you explain is amazing. Subbed!
@mikej9062
@mikej9062 3 года назад
This is a quiet but great tutorial.
@markh9646
@markh9646 6 лет назад
Thank you Kevin. Your videos are so helpful!
@KevinPowell
@KevinPowell 6 лет назад
Thanks Mark, glad to hear it :)
@SaleKnezevic
@SaleKnezevic 2 года назад
This one (mildly tweaked for translateY) worked as charm! Muchos gracias senor ;)
@aaronsoto3823
@aaronsoto3823 5 лет назад
This is amazing, I wish I had your knowledge to problem solve like this! Keep it up!
@Orechak
@Orechak 5 лет назад
I find it great the parallax--box has got to move slowly as people will try to read its content as you scroll. However, I was thinking, what if the parallax--box was a css animation and I want it to move upwards instead. Maybe I will try with the numbers. Thank you so much Kevin. You are helping me a lot.
@DrawCuriosity
@DrawCuriosity 7 лет назад
I just want to say I love the work you do here and express my appreciation in a comment :)
@KevinPowell
@KevinPowell 7 лет назад
You literally made my day! Thank you :D
@DrawCuriosity
@DrawCuriosity 7 лет назад
Kevin Powell so happy to hear that! keep up the great work
@afsanazamannipa7711
@afsanazamannipa7711 5 лет назад
Thank You for this video. The explanation of Parallax is really great and helpful. :)
@puppadread787
@puppadread787 7 лет назад
Thank you so much.
@marklauder973
@marklauder973 3 года назад
Thanks for a very useful tutorial. I was wondering about this line of code: if (offset > screenHeight && offset) - could you explain the offset > offset part. Many thanks.
@ramyadamarla6951
@ramyadamarla6951 3 года назад
Hey u are awesome 🤩..after applying this parallax ,my image repeating vertical ,if add background -repeat:no-repeat; my image is not visible showing white space..could please give me solution ..cheers
@skitzcod4
@skitzcod4 7 лет назад
the parallax--box: would've been a nice idea if the css was like top: 0; and when you scroll down it moves slowly up until it reaches -5em :D nice and clear tutorial!
@KevinPowell
@KevinPowell 7 лет назад
Glad you liked it 👍. And if you play around with it, I'm sure you could get that type of effect. In an older comment, I mentioned how you could stop it scrolling when it reaches a certain point
@oror301
@oror301 6 лет назад
I had a problem with the wScroll variable returning 0. If anyone is having this problem, you can use the vanilla JS solution of window.pageYOffset. Awesome job with this tutorial!
@KevinPowell
@KevinPowell 6 лет назад
What's the problem exactly?
@trenvert123
@trenvert123 6 лет назад
Great video! It's really cool that you explain why you do something instead of just saying that you _should_ do it to just get it to work. It shows that you've really prepared for this and want us to actually learn it. I did have a problem though. When resizing the web page, the image started repeating. This was especially obvious whenever I tried to scroll. Do you have any advice for this problem?
@KevinPowell
@KevinPowell 6 лет назад
Glad you like my approach trenvert123! It could be an issue with the size of the image, and it might also be where the image is located. There is a link in the description of the post to my codepen that has an updated bit of code for this, which *might* fix the issue.
@trenvert123
@trenvert123 6 лет назад
Kevin Powell Thanks for getting back to me so quickly! Lol. I was tinkering with the code for hours trying to find a perfect balance for the parallax and the image's current size. It never occurred to me that my image was simply too short. This solves my problem perfectly. Thank you.
@KevinPowell
@KevinPowell 6 лет назад
Glad that it worked out!
@luiscolome75
@luiscolome75 5 лет назад
Love it. Just what I'm looking for, for a WordPress Theme I'm developing. Thanks million!!
@svetoslavtrifonov6431
@svetoslavtrifonov6431 5 лет назад
if the box is way down this -5 will not work properly. Now is -5+0 and it is ok, but if it is -5 and lets say you are in the middle of the page for example scrollTop(2500) your element will be already moved down. You must apply this logic only when the desired element is detected something like elem.top - scrollTop = 0. Otherwise it is good example tnx. edit: Oh you did it in the codepen example my mistake :). Good tutorial
@TomWagstaff
@TomWagstaff 4 года назад
It's been a great series and everything has been going great until I got a warning message about $ not being defined, I presumed I had messed up a src link so I checked your code on GitHub and even copied directly to make sure I had it right and it's still giving me warnings. Anyone got any ideas?
@jezdant
@jezdant 4 года назад
Thanks so much for this tutorial, really great to see you problem solve on the fly too 👍🏻. I have the first example of parallax working well on a hero image, however it always starts the image at the top. Is there a way for the parallax movement to take into consideration the vertically centred image please?
@wetfrog82
@wetfrog82 3 года назад
var currentPosSt = $('.parallax-bg').css('background-position-y'); var currentPos = parseInt(currentPosSt); //turns returned string into integer function parallax(){ var wScroll = $(window).scrollTop(); $('.parallax-bg').css('background-position', 'center '+(currentPos +(wScroll*0.5))+'px'); } this works
@treycranson
@treycranson 6 лет назад
mixing em and px is tricky. this also explains why the box rocketed down your page.
@19hummer73
@19hummer73 6 лет назад
Thank you for sharing your knowledge
@KevinPowell
@KevinPowell 6 лет назад
No problem at all :D
@jaimesastre1046
@jaimesastre1046 5 лет назад
very interesting; I have to check what happens with more complex functions like (1/wScroll) or (wScroll - 1/wScroll) etc ...
@ДаниилКедров
@ДаниилКедров 5 лет назад
You are the best! Thank you for this video
@bvdizon
@bvdizon 6 лет назад
Thank you, Kevin! You are awesome. :)
@ethansmith5895
@ethansmith5895 5 лет назад
Thanks for this, Kevin! So helpful! I wanted to know how one might adapt the calculation in JS in order to enable the background position to start in a position other than position: center 0; . I'm hoping to having my background image start at position: center 100px; or even position: center center;
@KevinPowell
@KevinPowell 5 лет назад
Good question, lol. It would take some fiddling aroun with maybe, and it might also depend on the height of the image. Sorry that I don't have a more concrete answer.
@renatomanaia3221
@renatomanaia3221 7 лет назад
Hi! Nice effect Kevin. It's working fine but I have a little problem, maybe you can help me. When I start to scroll the page,right at the beginning, the background image suffer a little scale or size adjustment, and then the effect works fine. And still working fine till I refresh the page and start to scroll, again, the background-image dimension do the adjustment. Hope I made myself clear. :) Thanks!
@KevinPowell
@KevinPowell 7 лет назад
I honestly have no idea what might be causing that. Is the site live somewhere where I can see it? It sounds like the size of something is changing when you start to scroll, but I'm not sure why that would happen.
@NLNTZ
@NLNTZ 7 лет назад
Quick fix would be to change the initial css on the hero image to "background-position: center 0px" (instead of just 'background-position: center). That fixed it for me.
@KevinPowell
@KevinPowell 7 лет назад
Great thinking Nate, thanks for helping out!
@rovedajr
@rovedajr 7 лет назад
Yeah, that fixed it! Thanks.
@Mintflake
@Mintflake 5 лет назад
@@NLNTZ whoah , never thought i found this on youtube XD thanks a lot Lentz :)
@eliakimcharles6931
@eliakimcharles6931 4 года назад
Thank you man 🙌
@mohamedkhodary7831
@mohamedkhodary7831 6 лет назад
Thank you so much Kevin, would you please make a tutorial for Parallax with background videos instead of images ?
@KevinPowell
@KevinPowell 6 лет назад
I'd be really worried about performance, but it'd be the same as I did with the image in this video (not the background-image)
@mohamedkhodary7831
@mohamedkhodary7831 6 лет назад
Thank you so much Kevin, you are my ultimate weapon in web development
@moisescastillo3447
@moisescastillo3447 6 лет назад
Awesome, i like the desing, the work and everything, i wonder if you can make other video the effect parallax just with vanilla javascript, advanced like you maked, from de begining to the end, i mean, for seeing all the process, please ... thanks so much.
@KevinPowell
@KevinPowell 6 лет назад
I might just do this one of these days, since I've stopped using jQuery :)
@williangalvez4648
@williangalvez4648 Год назад
Hi Kevin, its any solution for the parallax iphone issue? Thanks, by the way you rocks ;-)
@erfin704
@erfin704 6 лет назад
amazing tutorial, it's super helpfull and easy to learn, can you post another tutorial about use parallax effect with mouse movement?
@KevinPowell
@KevinPowell 6 лет назад
I'll add it to my todo list :)
@erfin704
@erfin704 6 лет назад
@@KevinPowell thank you!!
@sunshizzleyou
@sunshizzleyou 7 лет назад
Thanks for the video +Kevin Powell - An issue i've seen often when experimenting with this is a background image in the middle of my site will completely disappear once I put in the JS code. Of course this could be difficult to answer and quite vague, however perhaps you could throw some ideas why this may happen for those of us that have this issue. Thanks! You're making the world a better designed place :)
@KevinPowell
@KevinPowell 7 лет назад
It's strange if the image is just missing... if you have a no-repeat on it, it could be that, by the time you scroll down to it, it's scrolled away. In the code I did in my video, I didn't take into account where on the screen the image was, in the codepen linked in the description, it is set up to have the image positioned perfectly, no matter how far down the page it is... if that doesn't solve the problem, I'm not sure what might be causing it :\
@sunshizzleyou
@sunshizzleyou 7 лет назад
Kevin Powell - thanks for the feedback and will recommend your channel.
@KevinPowell
@KevinPowell 7 лет назад
No problem, and thanks for recommending it!!
@armin_zi
@armin_zi 2 года назад
Thank you so much!
@587_mehulrana2
@587_mehulrana2 5 лет назад
what about mobile view does the parallax effect of text box would work and if it work how it would look like???
@katielane1326
@katielane1326 7 лет назад
Hello! New to coding and love this tutorial! I was wondering if you happen to know my issue. So if I click on and use the actual window scroll, it's beautiful, nice smooth scrolll. However, if I use my mouse pad on my laptop, it's quite jumpy. I made sure the transition was set to initial and my code looks like yours. Thoughts are appreciated! Thanks!
@KevinPowell
@KevinPowell 7 лет назад
I could be wrong, but I think it has to do with how the browser is interpreting the scrolling when you use your mouse pad? It might be moving it in jumps of X pixels, similar to how a mouse wheel is interpreted. We could fix it with some scroll jacking to make sure it's always smooth, but I personally *hate* scroll jacking, because it makes it not scroll in the way that I'm used to or expecting.
@katielane1326
@katielane1326 7 лет назад
Ahh. That makes sense. Would you suggest using something like Scroll Magic? Or do you have any animation libraries you personally like? Or would you consider that scroll jacking?
@KevinPowell
@KevinPowell 7 лет назад
Sorry for taking so long to reply! I like Scroll Magic, but even with their demo, I get the same problem. If I scroll with my mouse wheel, the magic hat animation is a bit janky, but if I use the scrollbar on the side, it's nice and smooth. Honestly, I'm not sure if there is a perfect solution. Please do let me know if you find something that you find works really good though! (and just because I'm not a fan of it doesn't mean that scroll jacking is inherently bad and you shouldn't use it, it's just my opinion!)
@KevinPowell
@KevinPowell 7 лет назад
Awesome!
@dmeskhi
@dmeskhi 7 лет назад
Hi Kevin, wonderful video! I have an issue with my background image. Everything works great according to the tutorial but the problem is that my bg image is repeating on scroll. Any tips/advice on that? Thank you in advance.
@KevinPowell
@KevinPowell 7 лет назад
Is your image further down your page? This will start scrolling things as soon as you start scrolling the page. If you follow the link in the description, there is an updated version that should fix your issue.
@dmeskhi
@dmeskhi 7 лет назад
Kevin Powell Thanks a lot. That was the problem.
@josephkwon9323
@josephkwon9323 6 лет назад
Great tutorial, only downside is that it's on jQuery and not vanilla JavaScript. Probably not much of a difference and not too difficult to look up though!
@KevinPowell
@KevinPowell 6 лет назад
I know :(. If I were to do this again, I'd do it with vanilla JS. Maybe one day!
@rickdeckard9810
@rickdeckard9810 7 лет назад
Thanks a lot for this, is it possible to have the text box scroll down to a specific position then stop rather than continue all the way down?
@KevinPowell
@KevinPowell 7 лет назад
If you wrapped everything inside an if statement, I think it would work... if(scroll < X) { $.parallax--box ....... } - where X is how far from the top you'd want it to stop at... so as long as your scroll is less than the number you put, it works, but then it stops doing that once you get past that point. Does that make sense?
@rickdeckard9810
@rickdeckard9810 7 лет назад
Hey Kevin thanks for the reply, yes it makes sense I'm sure to a programmer but unfortunately I'm not so I'll take your word for it. :)
@KevinPowell
@KevinPowell 7 лет назад
Haha, it's really hard to write these things out in a clear way, especially for people who are just learning. Let me know if you still looking to do this, I'll see if I can be more clear.
@cadentan8075
@cadentan8075 7 лет назад
Thanks for the great tutorial!!! It works out great on my site and I would like to know how to disable the parallax on mobile device.
@KevinPowell
@KevinPowell 7 лет назад
I'm glad you like the tutorial Caden! You should be able to use an if statement like this: if( $window.width() > 800 { // parallax stuff here } Here is a codepen as an example: codepen.io/kevinpowell/pen/ZeRwdz
@cadentan8075
@cadentan8075 7 лет назад
Thanks for the prompt reply!!! Greatly appreciated:)
@KevinPowell
@KevinPowell 7 лет назад
No problem! One of the advantages of having a small channel is that it's easy for me to keep up with the comments, hah. Seriously though, I'm glad I could help!
@Mintflake
@Mintflake 5 лет назад
how to create box like that , i mean that box are between 2 divs right ?? i tried but it always change its position , whenever i zoom in/out the page ! plz help :)
@banladutz9538
@banladutz9538 7 лет назад
Thanks! really helpful. No .js plugin needed. But how to stop the parallax effect of .parallax--box after it get to its normal position?
@KevinPowell
@KevinPowell 7 лет назад
I'm on mobile ATM, so I haven't tested this, but I think If you wrapped everything inside an if statement it would work... if(scroll < X) { $.parallax--box ....... } - where X is how far from the top you'd want it to stop at...
@banladutz9538
@banladutz9538 7 лет назад
yeah its working.. Thank you so much! :)
@KevinPowell
@KevinPowell 7 лет назад
Awesome! I'm really glad that worked 😁
@psasa01
@psasa01 7 лет назад
Hi Kevin, first, thank you very much for tutorials you are doing. I am new to jquery, followedthis tutorial and managed to make it on the page I am building. The problem I got is stuttering (going back down) in the beginning while background is still near the top. I know it has something to do with my navigations and waypoint. Is it ok to send you a link, maybe you can check it. Thanks in advance, Sasa
@KevinPowell
@KevinPowell 7 лет назад
As Nate Lentz helpfully mentioned, it might be fixed by changing the "background-position: center" to "background -position: center 0px". That keeps it horizontally centered, but will make the image align with the top of the div. If that doesn't work, let me know!
@psasa01
@psasa01 7 лет назад
Thank you very much. In the meantime I found the script for smooth scrolling, it kinda helped. I will try with center 0px also. Thanks again for the effort you put to teach us :) Cheers
@muurio
@muurio 7 лет назад
Great video! :) but I have a question: for one of my sections that uses this parallax effect the background image is split horizontally and just gets repeated after that. I couldn't figure out how to position it on the y-axis. My other section with that effect works fine. I hope you can understand what I mean...
@KevinPowell
@KevinPowell 7 лет назад
I'm happy you like the video Zari! Does 'background-size: cover' fix the problem by any chance?
@muurio
@muurio 7 лет назад
I already tried that but it didn't change anything :/ Is there any way I can move the image up on the y-axis?
@KevinPowell
@KevinPowell 7 лет назад
background-position can move things on both axis, but then it'll get changed with the parallax effect...
@muurio
@muurio 7 лет назад
Kevin Powell Yeah that's what happened. I guess I'm just stuck with it :/
@KevinPowell
@KevinPowell 7 лет назад
If you want it to start at a specific position, you could build that into the jquery. So $('.classname').CSS('position' , 'center ' + '300' + wHeight + 'px') That would stop it from jumping when you scroll. Obviously change the 300 for whatever is in your CSS.
@windowfitter1587
@windowfitter1587 7 лет назад
More like this mate
@KevinPowell
@KevinPowell 7 лет назад
Glad you liked it!
@cha-hin
@cha-hin 6 лет назад
I really like the way you did it. I just got a problem, my parallax isn't as smooth as yours and even less when I start scrolling up & down quick, do you have any solution? Thanks
@KevinPowell
@KevinPowell 6 лет назад
It could be related the the file size of the image. It's actually a pretty intensive thing for the browser to handle, and large images tend to kill performance.
@cha-hin
@cha-hin 6 лет назад
Okay I'm gonna try to change my image, thank you
@AlThePal78
@AlThePal78 3 года назад
so I am trying to do that what you are doing with 2 pictures for background fixed pictures in different sections, yet the second picture ends up at a halfway point, is there a solution for this?
@AlThePal78
@AlThePal78 3 года назад
great tutorial and its 2 years old aewsome
@hasmukhmevada6332
@hasmukhmevada6332 7 лет назад
u r real hero
@KevinPowell
@KevinPowell 7 лет назад
Thanks! Not sure I'd go that far, we're just building some websites, but I appreciate the sentiment 😀
@johanekberg14
@johanekberg14 7 лет назад
I want to have several backgrounds with text-boxes in between. How can I do that? When I use your code, it works for the first background, but the second background does not even appear. Can someone help me please? (great video btw!)
@KevinPowell
@KevinPowell 7 лет назад
When I made this, I thought it would work for multiple backgrounds, but yeah, it can cause problems, and that bugs me... I've come up with a few extra lines to add to the JS that should help, check them out here - codepen.io/kevinpowell/pen/YVOLGz
@johanekberg14
@johanekberg14 7 лет назад
Thank you very much! However I still got a problem. When I apply no-repeat on the background there's a white area above the picture. Also, when the div class for the parallax is empty, it does not display. How can I solve this problem?
@KevinPowell
@KevinPowell 7 лет назад
For the empty div thing, you'll want to use some padding top and/or bottom. As for the white bar, the best solution is to have the image be taller than the div... so if your div is 500px tall, aim for an image that's, say 1000px tall, so as it scrolls by, you have enough image that we can always see something.
@johanekberg14
@johanekberg14 7 лет назад
Thank you very much for the help man!
@KevinPowell
@KevinPowell 7 лет назад
No problem, glad I could help!
@pawanrathore1101
@pawanrathore1101 5 лет назад
This effect show repeated image on top how to fix it
@evgeniapereverzeva7065
@evgeniapereverzeva7065 6 лет назад
Hi,Kevin! I'm just wondering ,is it possible to make parallax effect without background-img but only with background(color)?
@KevinPowell
@KevinPowell 6 лет назад
If it's a solid color you wouldn't really notice it. I guess maybe with a gradient it would work.
@evgeniapereverzeva7065
@evgeniapereverzeva7065 6 лет назад
How exactly with a gradient do you mean?
@KevinPowell
@KevinPowell 6 лет назад
Well, if you have a solid color and you do a parallax, you won't really see that it's scrolling at a different speed... the effect is caused by the 'box' moving at one speed, and the image inside it moving at a different speed.
@ali_rehmatullah
@ali_rehmatullah 7 лет назад
I feel like I've seen window.scrollTop() set to a variable called 'wScroll' in a number of places, is this a common naming convention?
@KevinPowell
@KevinPowell 7 лет назад
Yup. It's a lot shorter than writing out windowScrollTop as a variable name, and it does a good job of letting you know what it's for :).
@s3bastiannaumann1996
@s3bastiannaumann1996 6 лет назад
-5 inside the brackets bc rn it's multiplying before adding???
@davidacosta6383
@davidacosta6383 5 лет назад
THANK YOU!!!
@christianjosephcunanan2870
@christianjosephcunanan2870 7 лет назад
Hi, is there any difference between making the background attachment: fixed on css and with the one you made on javascript? that's on .parallax--bg. Thanks
@KevinPowell
@KevinPowell 7 лет назад
I take a look at background-attachement: fixed at about the 1:45 mark. It works great, but it makes the image locked in place (it stays the same, as the rest of the page scrolls). With what I do in this video, the image still scrolls, but at a different speed than what the rest of the page is scrolling at.
@christianjosephcunanan2870
@christianjosephcunanan2870 7 лет назад
Hi, yeah i noticed that i just couldn't find my reply to correct my comment. your playlist is awesome i subscribed btw. looking forward to see other parallax effect tutorial PS: i used this tutorial on applying the effect instead of using the "background-attachment: fixed. good work
@KevinPowell
@KevinPowell 7 лет назад
For some reason your comment got classified as 'Likely spam', so I had to approve it for some reason. Thanks for subscribing, I'm glad you're enjoying the videos!
@boheeatelier6681
@boheeatelier6681 9 месяцев назад
cool! thanks :)
@korjeorayan3086
@korjeorayan3086 7 лет назад
I love your font.. Can I download it?
@KevinPowell
@KevinPowell 7 лет назад
The font I used on the website is Raleway, which you can get for free from Google fonts - fonts.google.com
@jasonyankee7818
@jasonyankee7818 7 лет назад
But what if I put this section with a parallax effect somewhere else, for example in the middle of the website. A background position is moving according to the scrollTop, therefore its gonna be ruined. Do you have any ideas how to make this universal?
@KevinPowell
@KevinPowell 7 лет назад
There is a link in the description to a codepen where I fix that exact issue!
@jasonyankee7818
@jasonyankee7818 7 лет назад
Thank you!
@KevinPowell
@KevinPowell 7 лет назад
No problem, hope it helps!
@johnywengy
@johnywengy 6 лет назад
Does this technique will work on mobile and tablets?
@KevinPowell
@KevinPowell 6 лет назад
It should work, but it can have some performance issues as the cpu is doing a lot of work for this.
@markalvinchua
@markalvinchua 6 лет назад
Is the wscroll measured in px rather em? Are they the same?
@KevinPowell
@KevinPowell 6 лет назад
pixels! Everything is always measured in pixels by the browser.
@Gaffer01
@Gaffer01 7 лет назад
Im going to be making a website for my Dad. Im a complete noobie at this and i have no idea what im doing. any tips for what im doing?
@KevinPowell
@KevinPowell 7 лет назад
Start simple. If you really have 0 experience, I do have a series that looks at the very basics. Be ready to not be able to get things exactly as you want them to start. What type of site are you making for him?
@Gaffer01
@Gaffer01 7 лет назад
Kevin Powell Yeah i have no knowledge, I will be sure to check out your series of the basics. Im trying just to make a Simple website in which there is a Gallary,Contact,About. Maybe a recessive Page?
@KevinPowell
@KevinPowell 7 лет назад
Yeah, keep it simple, and just do one page at a time. You get get frustrated at times, but you'll get there!
@Gaffer01
@Gaffer01 7 лет назад
Kevin Powell ok thanks!
@cyrill7143
@cyrill7143 7 лет назад
Nice tutorial but the effect could be 'generalized' by affecting its offset top position instead of doing it case by case.
@KevinPowell
@KevinPowell 7 лет назад
I totally wish I could go in and edit my video to fix this! Thanks for pointing it out though, I'm going to keep this pinned at the top in hopes that others see it.
@soliderofAlmighty
@soliderofAlmighty 7 лет назад
can you rewrite the code here so that everyone may see
@KevinPowell
@KevinPowell 7 лет назад
I already added a codepen with the new code to the description :) - Find it here: codepen.io/kevinpowell/pen/YVOLGz
@soliderofAlmighty
@soliderofAlmighty 7 лет назад
Kevin Powell thanks really appreciate
@Jade-pp3tl
@Jade-pp3tl 7 лет назад
amazing
@KevinPowell
@KevinPowell 7 лет назад
Thanks!!!
@mk9834
@mk9834 4 года назад
lovely
@valevallo
@valevallo 7 лет назад
Is there any reason my parallax.js is not working? Console log isnt showing or anything. My code is no different from yours. Any ideas? Great vid btw
@KevinPowell
@KevinPowell 7 лет назад
Hrm, not sure without seeing the code. Could it be an issue with linking to jQuery? Otherwise, I can't really say. If you put your code in a jsFiddle or CodePen I'll check it out if you'd like.
@valevallo
@valevallo 7 лет назад
I really appreciate that, but I figured out the issue. It was strange, everything worked in CodePen but not locally. Turns out I had overflow-x:hidden; in my css which was causing the problem. Weird.
@KevinPowell
@KevinPowell 7 лет назад
Glad you got it working!
@valevallo
@valevallo 7 лет назад
Thanks a lot Kevin. One last question. The parallax is smooth when using the scrollbar however its somewhat jerky when using the mouse wheel, is there a way to correct this somewhat? Thanks in advance.
@KevinPowell
@KevinPowell 7 лет назад
Not really (that I know of). It has to do more with the way the mouse wheel works, jumping a bit at a time, instead of moving pixels slowly. A magic mouse on a mac, or even some other mice would probably have a smoother experience. You could 'scroll jack' as well, where you use JS to control how the scrolling works when someone uses the mouse wheel, but that personally drives me nuts, because it changes how I expect my mouse wheel to work.
@danielaboagye124
@danielaboagye124 4 года назад
Which site did you copy the jquery source code can you please paste?
@KevinPowell
@KevinPowell 4 года назад
Try cdnjs
@danielaboagye124
@danielaboagye124 4 года назад
Sure thanks
@hernana6689
@hernana6689 5 лет назад
Thanks, it's very helpful..! And beautiful girl, indeed.
@jackma3674
@jackma3674 6 лет назад
It would be better if the black box appeared from the bottom to the top as u scroll...cuz otherwise the landing page looks ugly when the black box was some what popping up from the bottom....while scrolling the black box gains default position slowly it would look sexy 😎😎😎😎😎😎😎
@YourShaown
@YourShaown 6 лет назад
_nice_
@ashleysaleem-west5485
@ashleysaleem-west5485 5 лет назад
8:51 *A simpler solution:* *:not(.parallax--bg) { transition: all ease-in-out 250ms; } This will apply a transition to everything _except_ for the class .parallax--bg 😉
@KevinPowell
@KevinPowell 5 лет назад
Good point. Looking at my code I cringe though.... lol, not a good thing to set transitions to * for performance reasons.
@syediqbalahmed3176
@syediqbalahmed3176 5 лет назад
good
@adilahmed9899
@adilahmed9899 6 лет назад
This is great and amazing video so far. Hats off love sir i am enjoying your video #onlinewebustaad
@marcusunivers
@marcusunivers 7 лет назад
Its din't work on mobile device :( But for Desktop is this nice ;) Sorry for my language :)
@KevinPowell
@KevinPowell 7 лет назад
I should work on any device, though in general, it might be best if it doesn't work on mobile anyway, except for high-end phones, it might cause some performance issues.
@marcusunivers
@marcusunivers 7 лет назад
Kevin Powell I have the LG G5. I open my Webside in Chrome. It works but not when i scroll. Its a delay. Like a transition. But i dont have transition. On Desktop this works perfect. On mobile its legging horrobile. Here my Side. Go to Portfolio www.marcustutorials.tk Its not optimized for mobile. Dont be scared, im working 😂 Sorry for my bad english im from german :)
@arjunmarasini1626
@arjunmarasini1626 6 лет назад
Add background image. Set background attachment:fixed; voilaaa
@KevinPowell
@KevinPowell 6 лет назад
Definitely works, but it's not exactly the same as what I'm doing here, where both are moving, but at different speeds, as I also do it with a div, instead of only with background-images. I do think background-attachment: fixed is underused though!
@gosnooky
@gosnooky 7 лет назад
Audio is way too quiet
@KevinPowell
@KevinPowell 7 лет назад
I know, i fixed the issue in future videos, but nothing I can do in this one sadly.
@salma_techie
@salma_techie 3 года назад
lol am dead..
@akshitsingh9080
@akshitsingh9080 5 лет назад
your voice is too similar like brackeys!
@KevinPowell
@KevinPowell 5 лет назад
hah, never heard of him, but just checked, I see the similarity
@akshitsingh9080
@akshitsingh9080 5 лет назад
Haha