I would like to create a responsive video banner, and was able to insert the video, but after playing around with some css, could not remove the large padding that is above and below the html. I’m a beginner at coding, and have only been using tutorials to solve this issue.
This is for my Shopify website. The video itself is uploaded to Shopify (not a youtube video). I was able to get the video up and running, but there is a large amount of padding on the top and bottom of the video. However, on larger computers, this space is minimized. How can I make this responsive and have the video to be right up against the menu, with no padding above or below it (while being resized with different computer sizes).
Here is how the padding + video looks like in my website:
This is the code I currently use. Thanks in advance!
video {
position: static;
width: 100%;
height: auto;
padding-top: 0%;
padding-left: 0%;
}
<video autoplay="" muted="" loop="" id="myVideo">
<source src="https://cdn.shopify.com/s/files/1/0002/5441/0764/files/White_Back_2.mp4?1958" type="video/mp4">
</video>
2
Answers
I am going to work with what you gave us, so hopefully this can help. To have no padding above or below, use this:
As a test I made a small page to demonstrate.
This produces the desired results of having it right against the object above (In this case just a plain div). I also tested it with Google Chrome’s dev tools on different devices and the expected result remains. If this does not work, then something else in your application is likely causing the issue
The trick to fix that is to add a wrapper and give it a percentage top or bottom padding. Here’s the original article on the technique.