是否可以只改变CSS中背景位置的Y值? [英] Is it possible to change only the Y value of background position in CSS?
本文介绍了是否可以只改变CSS中背景位置的Y值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以只更改CSS中背景位置的Y值?
background-position-y
解决方案只有通过读取(使用JS)当前值
background- position
(如果未设置为内联,则使用计算样式方法),解析它以读取X值,然后使用刚刚检索的X值重新设置。 在CSS中没有办法说从层叠中获取背景位置X值和这个值的Y值。
Is it possible to change only Y value of background position in CSS?
background-position-y
is not a valid solution.
解决方案
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.
这篇关于是否可以只改变CSS中背景位置的Y值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文