【发布时间】:2014-08-01 04:44:01
【问题描述】:
我有一个background image which is getting scaled,,但问题是在较小的分辨率下它会变得拉伸并且看起来更丑。
.bcg {
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
height: 100%;
width: 100%;
}
/* Slide 1 */
#slide-1 .bcg {background-image:url('../img/bcg_slide-1.png');
background-size: 100% 100%}
HTML 标记
<section id="slide-1" class="homeSlide">
<div class="bcg">
<div class="hsContainer">
<div class="hsContent">
<h2>Hello1</h2>
</div>
</div>
</div>
</section>
如果我使用background-size: 100% auto;,那么它不是perfectly fitting the entire window。是否有任何解决方案可以使 div 中的 background-image 适合所有 resolutions 和 sizes。
【问题讨论】:
-
background-size: contain -
你试过"background-size": "contain" or "cover"
-
两者都不起作用...
-
您是否在移动版 Safari 中看到了这个问题?
background-size: cover有点不靠谱。如果是这样,您可能会发现 this earlier question 很有帮助。
标签: html css responsive-design