Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Strange additional width on Video element wrapper

I’m wrapping a video tag in a div to position a few components relative to the video player no matter what size the video has. But I’m stuck failing to locate what’s adding some extra width to my wrapper container.

.video-pop-up{
    display: none;
}
.video-pop-up.open{
    position: fixed;
    top:0;
    left:0;
    width:100vw;
    height:100vh;
    background: rgba(0,0,0,0.8);
    z-index: 99;
    display: grid;
    place-items: center;
}
.video-pop-up.open video{
    max-width: 95%;
    max-height: 95%;
}

.video-wrap{
    position: relative;
}
<div class="video-pop-up open">
  <div class="video-wrap">
    <video controls>
      <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
      </video>
    </div>
</div>

The container is this big:

Wrapper with padding

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

and the video element itself is this big:

Video element no padding

Can anyone see what is causing the added width of my wrapper container?

>Solution :

.video-pop-up.open video{
    max-width: 95%;
    max-height: 95%;
}

This right here is what’s causing that empty space. It’s not padding or margin, it’s the content box. In the child element (the video), you specified that the video only takes up 95% of the width of the parent container and 95% of the height of the parent container. So your parent container content-box now has 5% empty space width and 5% empty space height.

Change it to

.video-pop-up.open video{
    max-width: 100%;
    max-height: 100%;
}

or remove it altogether, and the video will take up all the space in the content-box of the .video-wrap container.

EDIT: punctuation.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading