您的位置:首页 > Web前端 > CSS

CSS中背景background-position负值定位深入理解

2013-03-30 15:07 676 查看
下面是我要用到的一个背景图,250*250像素,坐标值是从左上方开始的,向右和向下伸展的时候,坐标值为负!



这是css样式结构

<style type="text/css">
.style1 {
color: #FFFF00;
background: url(style/坐标图.png) no-repeat;
background-position: -25px -25px;
height: 50px;
width: 50px;
}

.style2 {
color: #FFFF00;
background: url(style/坐标图.png) no-repeat;
background-position: -75px -75px;
height: 50px;
width: 50px;
}

.style3 {
color: #FFFF00;
background: url(style/坐标图.png) no-repeat;
background-position: -125px -125px;
height: 50px;
width: 50px;
}
</style>


调用方法:

<p class="style1"></p>
<p class="style2"></p>
<p class="style3"></p>


显示效果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: