CSS background-position的定义和用法

如题所述

background-position 属性设置背景图像的起始位置。
这个属性设置背景原图像(由 background-image定义)的位置,背景图像如果要重复,将从这一点开始。
提示:您需要把 background-attachment 属性设置为 fixed,才能保证该属性在 Firefox 和 Opera 中正常工作。 默认值: 0% 0% 继承性: no 版本: CSS1 JavaScript 语法: object.style.backgroundPosition=center   如何定位背景图像:
body{ background-image:url('bgimage.gif');background-repeat:no-repeat;background-attachment:fixed;background-position:center;}
背景位置属性用于设置背景图像的位置,这个属性只能应用于块级元素和替换元素。其中替换元素包括img、input、textarea、select和object。 background-positon:长度单位/关键字;语法中的取值包括两种,一种是采用长度单位,另一种是关键字描述。长度单位指的是px、百分比等。 当background-position取值为关键字时,也需要设置水平方向和垂直方向的值,只不过值不是使用px为单位的数值,而是使用关键字代替。 属性值说明top left左上top center靠上居中top right右上left center靠左居中center center正中right center靠右居中bottom left左下bottom center靠下居中bottom right右下

温馨提示:答案为网友推荐,仅供参考