如何定义背景图片的位置?

MeChecksV 2009-05-13 10:42:01
background:#f4f7fb url(login.jpg) no-repeat;

如何定位这个图片的位置?



...全文
633 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
whj9980 2010-08-11
  • 打赏
  • 举报
回复
background:#f4f7fb url(login.jpg) no-repeat 12px 7px;
12px是向右平移
7px是向下平移
可以试试。
GeekZFZ 2009-05-13
  • 打赏
  • 举报
回复
学习
trench1022 2009-05-13
  • 打赏
  • 举报
回复
background:#f4f7fb url(login.jpg) 0px -10px no-repeat;

background:#f4f7fb url(login.jpg) top left no-repeat;
.
.
.

left top center right这几个就不说了
关键的东西就在用数字来定图片显示的起始位置:

你用ps打开一张图:

第一句里的0px指的是从图片的左上角(0,0)开始 , -10指的是(0,-10)这个位置开始显示图片!

具体的图片的显示位置你自己试验下,比我在这讲解来的快多了!

caiying2009 2009-05-13
  • 打赏
  • 举报
回复

<style>
td{background:#f4f7fb url(http://www.csdn.net/Images/logo_csdn.gif) no-repeat;
}
.t1{background-position:top center}
.t2{background-position:center right}
.t3{background-position:0 80%}
.t4{background-position: 10px 20px}
</style>
<table border="1" id="table1" width="440" height="307">
<tr>
<td class=t1> </td>
<td class=t2> </td>
</tr>
<tr>
<td class=t3> </td>
<td class=t4> </td>
</tr>
</table>

shenzhenNBA 2009-05-13
  • 打赏
  • 举报
回复
位置可以为 bottom , top , left, right
shenzhenNBA 2009-05-13
  • 打赏
  • 举报
回复
[Quote=引用楼主 MeChecksV 的帖子:]
background:#f4f7fb url(login.jpg) no-repeat;

如何定位这个图片的位置?
[/Quote]

background:#f4f7fb url(login.jpg) bottom no-repeat;
IcesDream 2009-05-13
  • 打赏
  • 举报
回复
mysite365 2009-05-13
  • 打赏
  • 举报
回复
语法:
background-position : length || length
background-position : position || position
取值:
length :  百分数 | 由浮点数字和单位标识符组成的长度值。请参阅 长度单位
position :  top | center | bottom | left | center | right

说明:
设置或检索对象的背景图像位置。必须先指定 background-image 属性。
该属性定位不受对象的补丁属性( padding )设置影响。
默认值为: 0% 0% 。此时背景图片将被定位于对象不包括补丁( padding )的内容区域的左上角。
如果只指定了一个值,该值将用于横坐标。纵坐标将默认为 50% 。如果指定了两个值,第二个值将用于纵坐标。
如果设置值为 right center ,因为 right 作为横坐标值将会覆盖 center 值,所以背景图片将被居右定位。
对应的脚本特性为 backgroundPosition 。

61,115

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧