Apnw2 Posted April 29, 2022 Share Posted April 29, 2022 Hello, I'm trying to create a parallax effect. On the CodePen I set the background by two means : the first one in HTML with src attr of img doesn't work. But as soon as i remove this src attr and set the image in JS using backgroundImage, it works. As in reality I'm trying to reproduce this effect with a background video (source tag inside a video tag instead of img tag), as far as I know I can't set the video url using JS and I'm obliged to use the src attr of source tag so the effect doesn't work. I don't understand why it doesn't work using src. So is there a way to do this effect with a video ? Thank's in advance See the Pen BaYBVVO by MaxOlliv (@MaxOlliv) on CodePen Link to comment Share on other sites More sharing options...
Solution Cassie Posted April 29, 2022 Solution Share Posted April 29, 2022 Hey there! Background position is a property of background images - you can't apply that to images in image tags or videos. It's best to animate transforms instead of background position though. Maybe this pen will give you what you need to get started. See the Pen OJzZpVZ by GreenSock (@GreenSock) on CodePen Good luck! 3 Link to comment Share on other sites More sharing options...
Apnw2 Posted May 1, 2022 Author Share Posted May 1, 2022 On 4/29/2022 at 5:53 PM, Cassie said: Hey there! Background position is a property of background images - you can't apply that to images in image tags or videos. It's best to animate transforms instead of background position though. Maybe this pen will give you what you need to get started. Good luck! It works, that's it. Thank you 🙂 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now