我有一個div(greenpromobox),它可以完美顯示在我的筆記本電腦和手機屏幕上。大屏幕尺寸的中心div(垂直和水平)
但是,在我的大顯示器上,它靠近頂部,在其周圍創造了大量的空白空間。
我想使用%來保持greenpromobox在垂直和水平中間,即使在大屏幕上也是如此。
直播鏈接:http://185.123.96.102/~kidsdrum/moneynest.co.uk/
HTML:
<div class="special">
<div class="jumbotron">
<div class="text-center">
<h1 class="boldme hidden-xs hidden-sm">Wish you were taught personal finance at school? We do too</h1>
<div class="greenpromobox">
<h2 class="boldme">Aged 20-30 and frustrated with money?</h2>
<h3 class="boldme">Take our free <b class="jumpstarttext">Jumpstart Your Finances</b> class to<br /> secure your financial future</h3>
<button data-sumome-listbuilder-id="d55c3ad2-17a7-47bb-9cf1-b16320caac27" class="text-uppercase btn btn-primary btn-lg-top">Start Class Now</button></div>
</div>
</div>
</div>
</div>
CSS
.greenpromobox {
background-color: green;
padding-top: 1px;
margin-top: 5%;
max-width: 740px;
border-radius: 5px;
text-align: center;
margin-left: auto;
margin-right: auto;
padding-bottom: 20px;
}
.jumbotron {
background-image: url("../img/young-people-with-no-money-worries.jpg");
background-size: cover;
color: white;
}
注:我使用的引導3.
我們可以使用position屬性在'.greenpromobox'這個屬性? –
就像你喜歡的@GauravAggarwal –