L
L
LegendaryI2015-11-06 15:23:53
css
LegendaryI, 2015-11-06 15:23:53

How to stretch the background video to the entire block?

There is the following page: imatte.ru/work/toster/man.html
The video is inserted as follows:

<video autoplay loop muted class="bgvideo" id="bgvideo">
    <source src="videos/man-page.mp4" type="video/mp4">
  </video>

.bgvideo {
  position: fixed;
  left: 0;
  top: 0;
  min-width: 100%;
  min-height: 100%;
  height: auto;
  width: auto;
  z-index: 0;
}

It is necessary to make it so that when the browser shrinks in height and width, the video is scaled and always stretches to the full width and height of the block between the menu and the footer.
Now, if the browser is narrowed, the video is cut off on the sides.
I tried a bunch of variations with width and height, and something is always wrong.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maximile, 2016-08-29
@Maximile

<div class="video_wrap">
    <video class="video_bg" autoplay="autoplay" loop="loop">
        <source src="video.m4v" type="video/mp4" />
        <source src="video.webm" type="video/webm" />
        <source src="video.ogg" type="video/ogg" />
    </video>
</div>

.video_wrap {
    position: absolute;
    overflow: hidden;
    background: url(/img/poster.jpg) center repeat;
    z-index: -999;
    min-height: 870px;
    max-height: 870px;
    display: block;
    width: 100%;
    max-width: 2560px;
}

.video_bg {
    display: block;
    position: relative;
    z-index: 0;
    margin: 0 auto;
    width: 125%;
}

This is how it came to me. Try.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question