這是我需要用我的HTML/CSS實現的內容,文本應該始終位於綠色容器內,無論屏幕大小如何。背景大小:封面與背景大小:包含
這是我的HTML:
<section id="aboutprocess">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<p class="text-center">Our agile team continuously delivers working software and empowers your organization to embrace changing requirements.
</p>
<button type="button" class="btn btn-link center-block white" role="link" type="submit" name="op" value="Link 2">about our process</button>
</div>
<!--end col-md-8 col-md-offset-2-->
</div>
<!--end row -->
</div>
<!--end container-->
</section>
<!--end aboutprocess-->
爲了達到這個觀點,我用background-size: contain
+ flexbox
:
#aboutprocess {
background: url("../img/tech_bg.png") no-repeat left top;
width: 100%;
height: 588px;
background-size: contain;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
#aboutprocess p {
color: #ffffff;
}
當我調整窗口的大小時,文字落在外面:
當我使用background-size cover
,綠色背景圖像不顯示原始形狀的任何更多:
我怎麼能使其發揮作用,這個綠色的背景保持其形狀和文字巋然不動此背景垂直和水平對齊。
這是鏈接to the demo page。
謝謝你的幫助。
使用含有除去固定的高度,並使用%,而非保持比例......但無論如何,在某些時候IMG合作太小,不能保持你想要的佈局 – DaniP