CSS background-origin

css background-origin 定义与用法

background-Origin属性指定background-position属性应该是相对位置。

注意如果背景图像background-attachment是"固定",这个属性没有任何效果。

默认值: padding-box
继承: no
版本: CSS3
JavaScript 语法: object object.style.backgroundOrigin="content-box"

 

css background-origin 语法

background-origin: padding-box|border-box|content-box;

 

描述
padding-box 背景图像填充框的相对位置
border-box 背景图像边界框的相对位置
content-box 背景图像的相对位置的内容框

 

css background-origin 浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

IE9+, Firefox 4+, Opera, Chrome, 和 Safari 5+支持background-origin属性

 

css background-origin 实例

内容框相对定位的背景图片:

div{
    background-image:url('smiley.gif');
    background-repeat:no-repeat;
    background-position:left;
    background-origin:content-box;
}

在线运行

 

相关文章

CSS3 教程: CSS3 Backgrounds