Jump to content
Search Community

Problem parallax effect with video

Apnw2 test
Moderator Tag

Go to solution Solved by Cassie,

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...