--- title: background-position-x slug: Web/CSS/background-position-x tags: - CSS - CSS Background - CSS Property translation_of: Web/CSS/background-position-x ---
background-position-x
CSS 属性设置水平方向的位置,与每个背景图片等位置层设置属性 {{cssxref("background-origin")}}相关。更多信息请查看{{cssxref("background-position")}}属性,这个用的比较普遍。
{{cssinfo}}
/* 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;
left
center
right
<length>
<percentage>
Specification | Status | Comment |
---|---|---|
{{SpecName('CSS4 Backgrounds', '#background-position-longhands', 'background-position-x')}} | {{Spec2('CSS4 Backgrounds')}} | Initial specification of longhand sub properties of {{cssxref("background-position")}} to match longstanding implementations. |
{{Compat("css/properties/background-position-x", "background-position-x")}}