小白教程
所有教程
关于
Search
172.70.127.162
172.70.127.162
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Pr background position”的源代码
本页内容
上一节:
Pr_background_color
下一节:
Css3_pr_background_size
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:background-position}}[[Category:css animatable|5]] = CSS background-position 属性 = 如何定位background-image: <sample title="" desc="" lang="html" hererun="1"> body { background-image:url('smiley.gif'); background-repeat:no-repeat; background-attachment:fixed; background-position:center; } </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <style> body { background-image:url('smiley.gif'); background-repeat:no-repeat; background-attachment:fixed; background-position:center; } </style> </head> <body> <p><b>注意:</b>该属性工作在 Firefox 和 Opera, background-attachment 属性会被设置为 "fixed"。</p> </body> </html> </run> == 标签定义及使用说明 == background-position属性设置背景图像的起始位置。 '''注意'''对于这个工作在Firefox和Opera,background-attachment必须设置为 "fixed(固定)". {| class="table table-striped table-hover" | 默认值: | 0% 0% |- | 继承: | no |- | 版本: | CSS1 |- | JavaScript 语法: | object object.style.backgroundPosition="center" |} == 浏览器支持 == 表格中的数字表示支持该属性的第一个浏览器版本号。 {| class="table table-striped table-hover" ! 属性 ! Chrome ! Internet Explorer / Edge ! Firefox ! Safari ! Opera |- | background-position | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |} '''注意:''' IE8 及更早的浏览器版本不支持一个元素有多个背景图片。 == 属性值 == {| class="table table-striped table-hover" ! 值 ! 描述 |- | left top left center left bottom right top right center right bottom center top center center center bottom | 如果仅指定一个关键字,其他值将会是"center" |- | x% y% | 第一个值是水平位置,第二个值是垂直。左上角是0%0%。右下角是100%100%。如果仅指定了一个值,其他值将是50%。 。默认值为:0%0% |- | xpos ypos | 第一个值是水平位置,第二个值是垂直。左上角是0。单位可以是像素(0px0px)或任何其他 [[css units|CSS单位]]。如果仅指定了一个值,其他值将是50%。你可以混合使用%和positions |- | inherit | 指定background-position属性设置应该从父元素继承 |} == 在线实例 == [[try.php?filename=trycss_background position|如何设置页面背景图像]] 这个例子演示了如何在页面上设置background-image。 [[try.php?filename=trycss_background position_percent|如何使用%来定位背景图像]] 这个例子演示了如何使用%设置页面上的图像位置。 [[try.php?filename=trycss_background position_pixel|如何使用像素来定位背景图像]] 这个例子演示了如何使用像素设置页面上的图像位置。 == 相关文章 == CSS 教程: [[css background|CSS Background]] CSS 参考手册: [[pr background image|background-image 属性]]
返回至“
Pr background position
”。
上一节:
Pr_background_color
下一节:
Css3_pr_background_size