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

后端 未结 6 2070
有刺的猬
有刺的猬 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: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.

提交回复
热议问题