Background video size

Hi all,

I am trying to use a background video for a thumbnail.

I have uploaded it the same size as the image next to it.
But it seems to display some sort of random size? :confused:

I really want it to display the correct size.
I’ve seen a few posts on here using custom code to fix this issue.
Is there a way to do this in webflow?

Any ideas?

Share link: https://preview.webflow.com/preview/website-4bb32c-4d3e757d57ce8edf9b7eda56?preview=44da2aea1d35b5152d2fa70d758fb3e3


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

First, this is not a specific issue of background-video (See “empty div example” below)

Why? You combine real images with bg-images/videos/color==== The div is empty!! & the height of the element set by padding/min/max-height/height) – for example:

And this is whats happen when i remove the height property (The video “disappear”):

Solution:

Try this trick (No custom code - but this is not dynamic (If in the future you change the sizes of the “real” images you should also change the padding-top %)

Why padding-top: 76.3%;?

Images size: 908 (width) / 1190 (height) X 100 = 76.3%

Empty div example:

Same idea with regular div with red background (To demonstrate this is not video issue)

Read more here:

2 Likes

this looks excellent :slight_smile: going to try it now

thanks once again

Why padding-top: 76.3%; ?

Images size: 908 (width) X 1190 (height) X 100 = 76.3%

^ is that right? I can’t seem to get 76.3% :thinking:

sorry. Divide.
(908 / 1190) = 0.76302

1 Like

ahh yes! thanks, that was driving me nuts :slight_smile:

1 Like

any idea why the video seems to be chopping off the top?

in this case, his head

No background-size: cover; for videos. The background-idea is more for a sky, clouds and so on (Not for content like faces -or- text). Maybe also this % trick wont work well with webflow styles.

Solution (maybe)

Webflow adds the video element (by js) - and add styles - so you must use custom code:

With inspect element this solve this issue (copy-paste before head)

<style>
   .w-background-video > video {
       width: 100%;
   }
</style>

before

After

2 Likes

Thank you again loads. I’ll try this trick and let you know if it works :slight_smile:

So the custom code works :slight_smile:
But only when I publish it. It doesn’t work when I look in preview?

Is this normal?

Great ! :slight_smile: Yes. Custom CSS “works” only on live url (Like JS).

1 Like

Ahhh I didn’t know this. Thanks again!

Hey again! I’m having trouble putting a background video on one of my pages.

Starting to think it might be that custom code interfering?

Basically it doesn’t seem to display.

If you could help again would be much appreciated!

Its on the SoftBank case study.

Share link - https://preview.webflow.com/preview/website-4bb32c-4d3e757d57ce8edf9b7eda56?preview=44da2aea1d35b5152d2fa70d758fb3e3

@ryan585 i dont see any video under this page. Write me in private - this Q not related to all users. Thanks

1 Like