CSS-背景位置-x | background-position-x
ackground-position-x
CSS 属性设置水平方向的位置,与每个背景图片等位置层设置属性 background-origin
相关。更多信息请查看background-position
属性,这个用的比较普遍。
/* Keyword values */ background-position-x: left; background-position-x: center; background-position-x: right; /* <percentage> values */ background-position-x: 25%; /* <length> values */ background-position-x: 0px; background-position-x: 1cm; background-position-x: 8em; /* side-relative values */ background-position-x: right 3px; background-position-x: left 25%; /* Multiple values */ background-position-x: 0px, center; /* Global values */ background-position-x: inherit; background-position-x: initial; background-position-x: unset;
注意:这个属性的值会被后面声明的属性覆盖掉,如background
和background-position
等简写的属性。
初始值 |
left |
---|---|
适用元素 |
all elements |
是否是继承属性 |
no |
Percentages |
refer to width of background positioning area minus height of background image |
适用媒体 |
visual |
计算值 |
A list, each item consisting of: an offset given as a combination of an absolute length and a percentage, plus an origin keyword |
Animation type |
discrete |
正规顺序 |
the unique non-ambiguous order defined by the formal grammar |
语法
值
left
在位置层上相对于左边的位置。center
在位置层上相对于中间点的位置。right
在位置层上相对于右边的位置。<length>
<length>
值是定义相对于位置层边缘的距离,边缘默认为左边。<percentage>
<percentage>
值是定义相对于位置层边缘的距离百分比,边缘默认为左边。
正式语法
[ center | [ left | right | x-start | x-end ]? <length-percentage>? ]#where <length-percentage> = <length> | <percentage>
规范
Specification |
Status |
Comment |
---|---|---|
CSS Backgrounds and Borders Module Level 4The definition of 'background-position-x' in that specification. |
Editor's Draft |
Initial specification of longhand sub properties of background-position to match longstanding implementations. |
浏览器兼容性
Feature |
Chrome |
Firefox |
Edge |
Internet Explorer |
Opera |
Safari |
---|---|---|---|---|---|---|
Basic Support |
(Yes) |
49.0 |
12 |
6 |
(Yes) |
(Yes) |
Two-value syntax (support for offsets from any edge) |
(No) |
49.0 |
12 |
9.0 |
(No) |
(No) |
Feature |
Android |
Chrome for Android |
Edge mobile |
Firefox for Android |
IE mobile |
Opera Android |
iOS Safari |
---|---|---|---|---|---|---|---|
Basic Support |
(Yes) |
(Yes) |
(Yes) |
49.0 |
? |
? |
? |
Two-value syntax (support for offsets from any edge) |
(No) |
(No) |
(Yes) |
49.0 |
? |
(No) |
(No) |
另见
background-position
background-position-y
- 多重背景(Multiple backgrounds)

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
-
上一篇
CSS-背景图片位置 | background-position
ckground-position指定背景图片的初始位置。这个初始位置是相对于以background-origin定义的背景位置图层来说的。 /* Keyword values */ background-position: top; background-position: bottom; background-position: left; background-position: right; background-position: center; /* <percentage> values */ background-position: 25% 75%; /* <length> values */ background-position: 0 0; background-position: 1cm 2cm; background-position: 10ch 8em; /* Multiple images */ background-position: 0 0, center; /* Edge offsets values */ background...
-
下一篇
CSS-背景位置-y | background-position-y
background-position-y属性用于设置初始状态时背景图片在垂直方向上的位置,这个位置相对于通过background-origin定义的背景层的原点进行定位. 需要获得更多的信息可以查看background-position属性,这个属性已经得到了长久且广泛的支持. 注意:background-position-y设定的值会被background或者是background-position的简写属性的background-position-x后面的值所覆盖. /* Keyword values */ background-position-y: top; background-position-y: center; background-position-y: bottom; /* <percentage> values */ background-position-y: 25%; /* <length> values */ background-position-y: 0px; background-position-y: 1cm; backgr...
相关文章
文章评论
共有0条评论来说两句吧...