I just started working with webflow a few weeks ago and so far, I am amazed with it.
However, I bumped into a problem that I just can’t find any solution to. For a client, I had to make a website with a hero video playing in the background.
My problem was the following: I’d like the video to automatically change size and manage the original 16:9 aspect ratio on tablet and mobile as well. So far I had tried a lot of different methods, different divs, paddings, widths and heights, but every time I try to test the website, the video starts playing as if it would have a lot more space, meaning, on tablet and mobile, you can only see the center of the video.
I tried using Vimeo and embedding that code, but since I don’t have Vimeo premium, I cannot hide the controls and make it autoplay.
EDIT: I found a solution to this problem that I am writing down in the main post as well.
To the custom head code in the project settings, inside the style tags.
I tested it with Chrome and Safari on Mac, and Safari on iPhone – it seems to be working on these browsers!
So I had an issue like this but with a static slider but I think it should work for this as well. Set your section with the background video to have a height of 56.25 VW which will make the hight scale perfectly to 16x9 based on the width. You may need to set the section to 100% wide, not sure.
As you can see, the problem happens when you actually visit the website on something other than desktop. The video starts playing, but a huge portion of it is ‘cut off’ compared to desktop, since it doesn’t resize itself to keep up with the device size, I hope you understand.
I’m just thinking loud but I think you might want to explore the padding-top hack to preserve the aspect ratio of your video. Here is a really interesting article about aspect ratio boxes on CSS tricks.
So let’s say your video as an 16:9 aspect ratio, you’d divide 9 by 16 and multiply that number by 100% and set that percentage based number (56.25%) to be your padding-top.
In other words: padding-top: calc(height/ width * 100%);
My hierarchy is the following:
I have a hero-video-wrapper div block, in which the hero-video element (background video) resides in. The hero-video element has a 100% width and 56.25 vw height on all screen sizes.
I added
the height/ width was just for the example sorry.
You could try replace calc(height/ width * 100%); by calc(9/ 16 * 100%); which is this 56,25%… (if your video has a 16:9 aspect ratio) you could simply write padding-top: 56%;
I tried what you wrote, and it still produces the same issue.
I’m starting to think this has something to do with the way the background video element works… sadly I have not found an other solution to upload my own video.
Okay, maybe the native Webflow background video isn’t enough for you.
I used custom code embeds in my website to display auto-played videos to showcase some the UI I designed in Webflow. Have a look here: https://www.anthonysalamin.ch/
You might want to explore that option too and combine it with the padding-top hack we talked about earlier. In your case, I would try to add a class to your <video> tag and target that class with CSS to modify its padding.
Thank you for your answer again. In the end, I found an answer while digging though the Inspector on the website. In case anyone struggles with this problem in the future:
@Levente - I just wanted to say that I love you for finding a solution for this. Seriously thank you! Seriously send me your Venmo and I’ll send you some money for a beer!
Thanks @Levente. I found that using your solution plus adding a top padding of 56.25% (for a 16:9 video) was the full solution for me.
I’ve been working on this for 3 weeks, trying every tutorial online, even tried third-party solutions. Nothing worked except your solution (plus top padding).
Thanks so much.
Really, Webflow should make this default. It’s kinda nuts otherwise.
HOT TIP! If you actually wanted to ‘zoom in’ the video (while keeping centered) for smaller screen sizes (not preserving the aspect ratio), you can add a >100% width value to the Background Video element. For example, I used 132vw and it worked a charm on my site. BE AWARE this causes overflow:hidden to not behave expected!
Thank you so much for mentioning Cloudinary. Been having issues of my own with a looping video idea for awhile and your post helped me solve it. I appreciate it!
Did you ever have trouble with Cloudinary lagging briefly or glitching, before it loops? I’m having an issue with the videos on my site hanging on to the last frame for a moment before looping.
I still cannot get the video the render properly on mobile. Desktop, tablet and landscape work but not mobile. I’m using the padding-top (56.25%) and the custom style code.
Hi,
I’m completely new to all this, what codes exactly do I have to place and where? I copied and pasted this and did not get any results. Do I have to add this code to code that should have been placed prior?
Just wanted to say thank you. Cloudinary is killer! I have heard of it in the past, hadn’t used it though, and after being frustrated with Webflow for the past 3 hours trying to embed Vimeo/YouTube/Background Video/etc. – all coming with their own limitations. Cloudinary worked without a hitch!