关于CSS中background样式的repeat和no-repeat的坐标问题

http://blog.sina.com.cn/s/blog_98eef7830101cv8t.html

最近在看css样式,这个背景平铺的坐标问题还挺困扰我的。总是搞不清楚。写一篇博文还总结一下!!


背景图片我画了一个200px*200px的方格。记为test.jpg
关于CSS中background样式的repeat和no-repeat的坐标问题
其实是思考贴上的背景小图,与div边框之间的数据关系。从哪里开始贴的,横做坐标表示在哪个点。
例如  no-repeat -50px -50px.就说明是从框外(左右方向-50,上下-50)开始贴的。
关于CSS中background样式的repeat和no-repeat的坐标问题


HTML中选用的是高250px,宽500px的边框2px的长方形

1.未带repeat和no-repeat也无横纵坐标
HTML:代码
background:url(test.jpg) ">
结果:
关于CSS中background样式的repeat和no-repeat的坐标问题关于CSS中background样式的repeat和no-repeat的坐标问题

2.仅有repeat-x
repeat-x url(test.jpg) ">
关于CSS中background样式的repeat和no-repeat的坐标问题

3.repeat-x 0px 100px
background: repeat-x 0px 100px url(test.jpg) ">

关于CSS中background样式的repeat和no-repeat的坐标问题

4.repeat-x 0px -100px
background: repeat-x 0px -100px url(test.jpg) ">
关于CSS中background样式的repeat和no-repeat的坐标问题
5.repeat-x -50px -100px
background: repeat-x -50px -100px url(test.jpg) ">
关于CSS中background样式的repeat和no-repeat的坐标问题
6.repeat-x -50px 100px
background: repeat-x -50px 100px url(test.jpg) ">
关于CSS中background样式的repeat和no-repeat的坐标问题

7.repeat-x 50px 100px
repeat-x 50px 100px url(test.jpg) ">
关于CSS中background样式的repeat和no-repeat的坐标问题
 8.repeat-x bottom(诡异)
repeat-x bottom url(test.jpg) ">
关于CSS中background样式的repeat和no-repeat的坐标问题
 repeat-x top:(也诡异,不规范,为何不从00开始呢?)
关于CSS中background样式的repeat和no-repeat的坐标问题

9.repeat-x left(靠小图左从左边中间平铺)
关于CSS中background样式的repeat和no-repeat的坐标问题
 repeat-x right(靠小图右从右边按照X轴平铺)
关于CSS中background样式的repeat和no-repeat的坐标问题
注意repeat-y与repeat-x结果相似。只能用repeat-y bottom/top,否则出错

10.no-repeat 
no-repeat  url(test.jpg) ">
关于CSS中background样式的repeat和no-repeat的坐标问题

no-repeat top
no-repeat top  url(test.jpg) ">
注: bottom则是居中靠下
关于CSS中background样式的repeat和no-repeat的坐标问题
no-repeat left
 注意:no-repeat right则是居中靠右
关于CSS中background样式的repeat和no-repeat的坐标问题
11.no-repeat left 100px(靠左边,则左为0,x坐标取0,只写上下)
no-repeat left 100px url(test.jpg) ">
关于CSS中background样式的repeat和no-repeat的坐标问题

no-repeat right 100px(靠右边则右边为0,只写上下方向,取正100)
background: no-repeat right 100px url(test.jpg) ">
关于CSS中background样式的repeat和no-repeat的坐标问题

12.no-repeat 100px bottom (靠下(代表上下),所以只用写左右,100px)
no-repeat 100px  bottom url(test.jpg) ">
关于CSS中background样式的repeat和no-repeat的坐标问题
注:同理no-repeat 100px top 这种写法也正确
13.no-repeat -50px -50px 
关于CSS中background样式的repeat和no-repeat的坐标问题

14.no-repeat -50px 50px (距离左边-50px,上边50px)
关于CSS中background样式的repeat和no-repeat的坐标问题

15.no-repeat -50px (距离左边-50px,上下默认,居中)
关于CSS中background样式的repeat和no-repeat的坐标问题



16.no-repeat -50px  top = no-repeat -50px 0px (距离div边界左边-50,上边0px)
关于CSS中background样式的repeat和no-repeat的坐标问题

同理no-repeat left 50px =no-repeat 0px 50px(左边0,上面50)
关于CSS中background样式的repeat和no-repeat的坐标问题


17.no-repeat left  top (靠左上,=0px,0px)=只有no-repeat
关于CSS中background样式的repeat和no-repeat的坐标问题
类似:no-repeat right bottom是靠div右下角贴
关于CSS中background样式的repeat和no-repeat的坐标问题



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值