我想在桌面顯示器上顯示寬幅圖像(圖像的頂部爲max-height:500px;)和移動設備的原始高寬比。圖像響應式網頁設計的頂部作物
我在Wordpress網站上使用龍門框架。我已經使用了CSS工作來強制圖像在父裝箱容器外顯示全寬。
示例除了在圖像高度小於最大高度時將空間推到頂部時,這種作物從頂部開始?
.boxed-container{
margin:30px;
padding: 30px;
background:red;
}
.bg-img{
position: relative;
display: block;
overflow: hidden;
padding: 0px;
margin: 0px;
width: 100vw;
height: 100vh;
max-height: 300px;
left: 50%;
right: 50%;
margin-left: -50vw !important;
margin-right: -50vw !important;
background: url(http://www.photographymad.com/files/images/rule-of-thirds-movement.jpg) no-repeat bottom;
background-size: 100% auto;
}
h1 {
position: absolute;
width: 100%;
bottom: 0px;
text-align: center;
margin-bottom: 0px;
}
<div class="boxed-container">
This is where the boxed content belongs.
<div class="bg-img">
<h1>This is the header</h1>
</div>
</div>
你能說出你的目標更清楚些嗎? – MeltingDog
你看到我的答案嗎? –
是的,我確實看到你的答案謝謝你,這是非常有益的和工作。 –