拉伸和缩放CSS背景是否有一种方法可以在CSS中获得一个背景来拉伸或缩放来填充它的容器?
3 回答

杨魅力
TA贡献1811条经验 获得超6个赞
background-size
:
body { background-image: url(bg.jpg); background-size: cover;}
cover
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='.myBackground.jpg', sizingMethod='scale'); -ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='myBackground.jpg', sizingMethod='scale')";

一只斗牛犬
TA贡献1784条经验 获得超2个赞
<div id="background"> <img src="img.jpg" class="stretch" alt="" /></div>
#background { width: 100%; height: 100%; position: absolute; left: 0px; top: 0px; z-index: 0;}.stretch { width:100%; height:100%;}
.stretch { min-width:100%; min-height:100%; width:auto; height:auto; }
- 3 回答
- 0 关注
- 775 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消