html - Background video with 100% width and fixed height -


i need run video in background. requirements video have run on 100% width , 600px height/max-height. here tried do.

https://jsfiddle.net/yydkd5t4/1/

html

<video autoplay loop muted id="video-bg">  <source src="http://demosthenes.info/assets/videos/polina.mp4" type="video/mp4">  </video> 

css

#video-bg { position: fixed; right: 0; bottom: 0; width: auto; min-width: 100%; height: auto; min-height: 100%; z-index: -100; background: transparent url(video-bg.jpg) no-repeat; background-size: cover; } video {display: block;} 

the issue facing when try fix height scale down width. solution problem highly appreciated.

after understanding trying achieve...

you need add parent div video. else maintain aspect-ratio , can't achieve want.

#video-bg {    position: relative;    width: auto;    min-width: 100%;    height: auto;    background: transparent url(video-bg.jpg) no-repeat;    background-size: cover;  }  video {    display: block;  }  .video-container {    width: 100%;    max-height: 600px;    overflow: hidden;    position: fixed;    top: 0;    right: 0;    z-index: -100;  }
<!--[if lt ie 9]>  <script>  document.createelement('video');  </script>  <![endif]-->  <div class="video-container">    <video autoplay loop muted id="video-bg">        <source src="http://demosthenes.info/assets/videos/polina.mp4" type="video/mp4" />      </video>  </div>

the problem current code or answers till won't maintain height: 600px because video maintain aspect-ratio.

so, add parent div width: 100% , max-height:600px overflow:hidden. way if video gets bigger height hidden parent div.

this best way achieve want, keep in mind hide parts of video.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -