2016-02-18 68 views
0

我有一個帶有自動播放背景視頻的Jumbotron。用Div/Jumbotron填充瀏覽器高度的100%

我想這填寫100%的用戶瀏覽器窗口(所以文本'你需要幫助?'只在滾動顯示)。

我該如何做到這一點?

直播網址:http://185.123.96.102/~kidsdrum/moneynest.co.uk/

CSS

.jumbotron { 
color: white; 
position:relative; 
overflow:hidden; 
height:500px; 
margin-bottom: -500px; 
z-index: -1; 
} 


    html,body {height:100%;} 
.special,.special .jumbotron 
{height:100%; 
width: 100%; 
    margin: 0px; 
    padding: 0px; 
border-radius: 0px; 
} 

.fullscreen-bg { 
    position: fixed; 
    top: 0; 
    right: 0; 
    bottom: 0; 
    left: 0; 
    overflow: hidden; 
    z-index: -100; 
} 

.fullscreen-bg__video { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
} 

@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%; 
    } 
} 

@media (max-width: 767px) { 
    .fullscreen-bg { 
    background: url('../img/videoframe.jpg') center center/cover no-repeat; 
    } 

    .fullscreen-bg__video { 
    display: none; 
    } 
} 

HTML

<div class="jumbotron"> 
<div class="fullscreen-bg"></div> 
<div class="container special"> 
<video loop muted autoplay poster="img/videoframe.jpg" class="fullscreen-bg__video"> 

     <source src="http://185.123.96.102/~kidsdrum/moneynest.co.uk/vid/people-with-no-money-worries.mp4" type="video/mp4"> 

    </video> 
</div></div> 


    <div class="container text-center"> 
    <div class="h1extrapadding hidden-xs hidden-sm"></div> <h1 class="boldme">Aged 20-30 & frustrated with money?</h1> 
    <div class="greenpromobox"> 
    <div class="h2extrapadding hidden-xs hidden-sm"></div> <h2 class="boldme">Take our free <b class="jumpstarttext">Jumpstart Your Finances</b> class to<br /> quickly gain control over your finances</h2> 


      <!-- Begin MailChimp Signup Form --> 
<div id="mc_embed_signup"> 
<form action="//moneynest.us11.list-manage.com/subscribe/post?u=9ccf2d2219536b32eaae3c3d1&amp;id=299de51b4e" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate> 
    <div id="mc_embed_signup_scroll"> 


        <img src="http://185.123.96.102/~kidsdrum/moneynest.co.uk/img/hand-drawn-arrow.png" id="handarrow" class="hidden-xs hidden-sm" alt="arrow"><input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="Enter your email address" required autofocus> 
    <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups--> 
    <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_9ccf2d2219536b32eaae3c3d1_299de51b4e" tabindex="-1" value=""></div> 
    <div class="clear"><input type="submit" value="Start Class Now" name="subscribe" id="mc-embedded-subscribe" class="text-uppercase btn btn-primary btn-lg"></div> 
    </div> 
</form> 
</div> 

<!--End mc_embed_signup--> 

</div> 
</div> 

</div> 
</div> 
    </div> 
+0

[div/jumbotron中錯誤放置背景視頻]可能的重複(http://stackoverflow.com/questions/35481620/incorrect-placement-of-background-video-in-div-jumbotron) – dippas

回答

0

這將是使你的div的100%,超大屏幕100vh的組合。

試試這個:

.jumbotron { 
color: white; 
position:relative; 
overflow:hidden; 
height:100vh; 
margin-bottom: -500px; 
z-index: -1; 
} 

我真的不能告訴無需代碼的小提琴。

0

使用視口高度上的超大屏幕(vh)值:

.jumbotron { 
    height: 100vh; 
} 

採取這種遠一點,我會用一個父/子選擇,而不是宣稱毯.jumbotron類,即:

.parent .jumbotron { 
    height: 100vh; 
} 

這是因爲您可能想要在另一頁上使用.jumbotron,並且不希望它去100vh,但顯示默認(BootStrap)方式。

編輯 - 也注意到在超大屏幕的下邊距......你可能想.jumbotron風格刪除這樣的:

margin-bottom: -500px; 

這實質上拉動下面的內容上的頂部視頻...

+0

謝謝大衛,這填補了視頻(真棒 - 謝謝!),但仍然保持「你需要什麼與「在瀏覽器窗口中,我應該使用邊緣推下來還是有更好的方法? –

+0

@SamJefferies啊,參見編輯答案。 –

+0

嗨大衛,我想要的視頻內容,只是沒有通過綠色股利。我想我可以在所有進一步的div中添加margin-bottom,但它不覺得做正確的事情>? –