【发布时间】:2016-09-04 19:39:41
【问题描述】:
我正在尝试使图像具有响应性,使用 contain 作为 background-size,但高度始终为 0。我已经在父元素上设置了高度,我缺少什么?
.masthead .container {
height: 300px;
}
.masthead-title {
margin-top: 0;
margin-bottom: 0;
color: #505050;
background-image: url('../logo.png');
background-repeat: no-repeat;
background-size: contain;
background-position: center center;
}
<div class="masthead">
<div class="container">
<label for="sidebar-checkbox" class="sidebar-toggle"></label>
<h3 class="masthead-title">
<a href="/" title="Home"></a>
</h3>
</div>
</div>
【问题讨论】:
标签: html css responsive background-size