Self-adjusting video

Asked

Viewed 98 times

0

Good am using HTML5 which in turn has a tag called <video> only that I am having many difficulties to use my video in the header of my site because I can not handle my video properly I would like my video to look like this website i can even but I have to put the height values in my code so if I caught a smaller screen the video gets big if I put on a bigger screen my video gets small realize that the video of this site there it is auto adjustable it and always 100% width and height follows an example the way I did however not very sure why fail height values with the tag transform:scale(); I think it’s wrong:

header {
  position: relative;
  top: 0;
  overflow: hidden;
  width: 100%;
  height: 90%;
  min-height: 850px;
}
video {
  height: 760.4375px;
  width: 100%;
  z-index: -10;
  top: 0;
  left: 0;
  -webkit-transform: scaley(1.72);
  -o-transform: scaley(1.72);
  -ms-transform: scaley(1.72);
  -moz-transform: scaley(1.72);
  transform: scaley(1.72);
  z-index: -2;
  position: absolute;
}
#bg-video {
  overflow-y: hidden;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url(../images/overlay.png);
  z-index: 1
}
.texto-header {
  position: absolute;
  top: 20%;
  left: 50%;
  margin-left: -280px;
  width: 630px;
  text-align: center;
  z-index: 2;
  color: #FFF;
}
.texto-header h1 {
  font-family: Gabriola;
  font-size: 4em;
}
.texto-header strong {
  color: #f80;
}
.texto-header p {
  /*font-family: 'Scada', sans-serif;*/
  font-family: Gabriola;
  font-size: 1.2em;
  line-height: 20px;
  margin-top: -5%;
}
.texto-header a {
  color: #fff;
  background: transparent;
  border: 2px solid #fff;
  padding: 13px;
  font-family: Gabriola;
  font-size: 1.2em;
  border-radius: 5px;
}
.texto-header a:hover {
  color: #000;
  background-color: #fff;
}
<header>
  <div id="video">
    <video id="Video1" class="bgvid" loop autoplay>
      <source src="video/League-warrios.mp4" type="video/mp4" />desculpe mais seu navegador não suporta este formato ou esta desatualizado :(
    </video>
  </div>
  <div id="bg-video"></div>

  <div class="texto-header">
    <h1>Olá amigos somos a <strong>Nova Era !</strong></h1>
    <p>dolor sit amet, consectetur adipiscing elit. Sed at risus neque.
      <br>Cras sit amet ligula ut justo commodo porta id ut enim. Nulla est lectus, mollis sit amet vehicula id, volutpat eget mauris.</p>
    <br/>
    <a href="#circulo">Então podemos começar ???</a>
  </div>



</header>

NOTE: My video has a background like the site mentioned above which is called overlay and I don’t care if I have to manipulate the video via java script because I don’t know what else to do to get the result I want

  • 1

    You have to look for information on media queries.

1 answer

0

Staff I found the answer I managed to do I will reply my own post because in case someone needs it one day this post can help:

<div id="video-bg">
      <video autoplay loop id="volume-js">
        <!-- Default video source: -->
        <source type="video/mp4" src="video/myvid.mp4"
                media="(orientation:landscape)">
      </video>
    </div>

the css:

#video-bg {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  overflow: hidden;
}

#bg-video{
  background-image: url(../images/overlay.png);
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
}

#video-bg > video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
}

/* 1. No object-fit support: */
@media (min-aspect-ratio: 16/9) {
  #video-bg > video { height: 300%; top: -100%; }
}

@media (max-aspect-ratio: 16/9) {
  #video-bg > video { width: 300%; left: -100%; }
}

/* 2. If supporting object-fit, overriding (1): */
@supports (object-fit: cover) {
  #video-bg > video {
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover;
  }
}

this code will leave the video full screen 100% x 100% without losing resolution or quality it does not stretch the video nor distort (however the video has to be of quality) =3

Browser other questions tagged

You are not signed in. Login or sign up in order to post.