我需要将我的背景放在屏幕的底部.但在移动设备分辨率上,我希望将其显示为低于100px,例如“bottom minus 100px”.是否可以在CSS中实现这样的功能? 是的,使用background-position属性的四值语法
介绍
// This two-value declaration background-position: center bottom // Is equivalent of this four-value declaration background-position: center 0px bottom 0px
免责声明:支持Chrome 25,Firefox 13,IE9,Safari 7
在你的情况下
因此,您可以将背景定位为“底部减去100px”:
background-position: center bottom -100px
例:
.container {
height: 190px;
padding: 1em;
margin: 0 auto 1em;
border: 1px solid #333;
text-align: center;
background-image: url('http://lorempixel.com/200/140/city/4');
background-repeat: no-repeat;
background-position: center bottom;
}
.plus {
background-position: center bottom 20px;
}
.minus {
background-position: center bottom -20px;
}
<div class="container">
background-position:<br>
center bottom
</div>
<div class="container plus">
background-position:<br>
center bottom 20px
</div>
<div class="container minus">
background-position:<br>
center bottom -20px
</div>
见MDN documentation
