ryan585
(ryan585)
August 5, 2018, 11:05am
1
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?
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:
html, css
2 Likes
ryan585
(ryan585)
August 6, 2018, 1:13pm
3
this looks excellent going to try it now
thanks once again
ryan585
(ryan585)
August 6, 2018, 1:24pm
4
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%
sorry. Divide.
(908 / 1190)
= 0.76302
1 Like
ryan585
(ryan585)
August 6, 2018, 1:28pm
6
ahh yes! thanks, that was driving me nuts
1 Like
ryan585
(ryan585)
August 6, 2018, 1:48pm
7
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
ryan585
(ryan585)
August 6, 2018, 4:40pm
9
Thank you again loads. I’ll try this trick and let you know if it works
ryan585
(ryan585)
August 8, 2018, 11:55am
10
So the custom code works
But only when I publish it. It doesn’t work when I look in preview?
Is this normal?
ryan585:
So the custom code works
Great ! Yes. Custom CSS “works” only on live url (Like JS).
1 Like
ryan585
(ryan585)
August 9, 2018, 10:45am
12
Ahhh I didn’t know this. Thanks again!
ryan585
(ryan585)
August 13, 2018, 8:07pm
13
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