我想在桌面显示器上显示宽幅图像(图像的顶部为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
你看到我的答案吗? –
是的,我确实看到你的答案谢谢你,这是非常有益的和工作。 –