how do you center vertically a video inside a video tag? currently the video is flush top and the bottom is getting cut off. what i would like to do is for the middle of the video to be in the middle of the video container. the video's height will vary because it's responsive so as the browser becomes smaller so does the video. here's my code:
html
<div id="video-wrap">
<video preload="auto" autoplay loop muted>
<source type="video/mp4" src="video.mp4">
</video>
</div>
css:
#video-wrap {
width: 100%;
height: 400px;
overflow: hidden;
}
You can either set the video's width in HTML or use the CSS' width property. In CSS, select the center class and set the text-align property to center . Thus, the video will be centered.
Select the text that you want to center. in the Page Setup group, and then click the Layout tab. In the Vertical alignment box, click Center.
These three lines should do:
video{
position: relative;
top: 50%;
transform: translateY(-50%);
}
Let me know if it works :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With