【css】展示背景图片的底部部分
利用背景图的background-position 实现
demo
方法一:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.box{
position:relative;
width:200px;
height:200px;
border:1px solid red;
background:url(../images/heightbig.jpg) no-repeat scroll 0 -232px ;
background-size:100%;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
原图

效果:

方法二(推荐):
.box{ position:relative; width:200px; height:200px; border:1px solid red; background:url(../images/heightbig.jpg) no-repeat; background-size:100%; background-position: bottom; }
拓展:
background-attachment设置背景图像是否固定或者随着页面的其余部分滚动。
作者:smile.轉角
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.
欢迎关注我,一起进步!扫描下方二维码即可加我QQ
浙公网安备 33010602011771号