CSS那个背景图片的坐标怎么设置?怎么计算的?

2025-02-23 19:28:13
推荐回答(3个)
回答1:

背影图片的左上角相对当前元素左上角的坐标。 

右为X轴正半轴, 下为Y轴正半轴

当前元素左上角坐标为 0,0

默认图片的左上角正对当前元素的左上角

如果图片想向左移 10px;

background:url(images/hh.gif) no-repeat -10px 0;}

如果图片想向上移 10px;

background:url(images/hh.gif) no-repeat 0 -10px;} 

同样

如果图片想向右移 10px;

background:url(images/hh.gif) no-repeat 10px 0;} 

做了个图片, 黑色框是要加背景的容器。

css代码: background:url(images/hh.gif) no-repeat -10px -10px;}

回答2:

background:url(images/hh.gif) no-repeat -10px 20px;}

:号后的由空格分出的4个属性分别是 背景图的

图片url路径 是否重复 向左移动像素 向下移动像素

回答3:

学习了