2017-10-28 81 views
-1

正如您在我提供的視頻中看到的視頻不是全寬,我希望它適合容器的其餘部分。誰能告訴我什麼,我做錯了,這裏是圖像: Image of the div and video視頻將不會填充容器的寬度

代碼:

HTML

<section class="content-2"> 
    <div class="fullscreen_bg"> 
    <video loop muted autoplay poster="img/videoframe.jpg" class="fullscreen-bg_video"> 
      <source src="images/Ajvar.mp4" type="video/mp4"> 
      <source src="movie.ogg" type="video/ogg"> 
      Your browser does not support the video tag. 
    </video></div> 
    </section> 

CSS

.content-2 { 

height: 350px; 
overflow: hidden; } 

.fullscreen-bg { 

max-height:350px; 
width: 100%; 
height: 100%; 
position: relative; 
padding:0; 
margin:0; 
left: 0px; 
top: 0px; 
z-index: -1000; 
overflow:hidden;} 


.fullscreen-bg__video { 
position: absolute; 
top: 0; 
left: 0; 
min-height: 100%; 
z-index: -100; 
background-size: cover; 
overflow: hidden;} 

@media (min-aspect-ratio: 16/9) { 
.fullscreen-bg__video { 
    height: 300%; 
    top: -100%; 
     } 
     } 

@media (max-aspect-ratio: 16/9) { 
    .fullscreen-bg__video { 
    width: 300%; 
    left: -100%; 
    } 
    } 
+0

把你的視頻代碼中的div fullscreen_bg內 –

+0

感謝您的答覆,我做到了,但還是同樣的事情:/ –

回答

0

嘗試視頻標籤的寬度屬性:

<video loop muted autoplay poster="img/videoframe.jpg" class="fullscreen-bg_video" width="350" height="350"> 
    <source src="images/Ajvar.mp4" type="video/mp4"> 
    <source src="movie.ogg" type="video/ogg"> 
    Your browser does not support the video tag. 
</video> 
+0

<視頻環靜音自動播放海報=「IMG/videoframe.jpg」級=「全屏-bg_video「width =」350「height =」350「> 您的瀏覽器不支持視頻標籤。 –

+0

這會更好,你發佈格式化的代碼在你的答案,而不是評論。 –