Is it possible to change only the Y value of background position in CSS?

后端 未结 6 2051
有刺的猬
有刺的猬 2021-01-19 06:56

Is it possible to change only Y value of background position in CSS?

background-position-y is not a valid solution.

相关标签:
6条回答
  • 2021-01-19 07:00

    Just try this

    background-position-y: 10px;
    

    Worked fine for me

    0 讨论(0)
  • 2021-01-19 07:01

    No, that's not possible. While background-position allows only one value to be set, this would define x only and make y center. Everything else, like background-position-y is non-standard and therefore only supported in some browsers.

    0 讨论(0)
  • 2021-01-19 07:01

    background-position-y: xpx should work.

    Can you show the code see we can see why it might not be working?

    0 讨论(0)
  • 2021-01-19 07:01

    use background-position:0px ypx;

    0 讨论(0)
  • 2021-01-19 07:02

    According to caniuse.com and this SO Question, background-position-y is now standard and supported in all browsers except older versions of Firefox.

    background-position-x/-y, background-repeat-x/-y approved for level 4 of backgrounds and borders.

    0 讨论(0)
  • 2021-01-19 07:06

    Only by reading (with JS) the current value of background-position (using a computed style method if it isn't set inline), parsing it to read the X value and then setting it again using the X value you just retrieved.

    There is no way to say "Take the background position X value from the cascade and the Y value from this" in CSS.

    0 讨论(0)
提交回复
热议问题