将像素转换为百分比 [英] Transition pixel to percent
本文介绍了将像素转换为百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用CSS进行转换,但是在:hover
事件中,我的元素的尺寸通常以像素为单位,但是以百分比表示,转换不会像这个。
I would like do a transition using CSS, but my element's dimensions are in pixels normally but in percent during the :hover
event, and the transition doesn't work like this. Do you know any way to do this?
推荐答案
您可能必须使用JavaScript将百分比值更改为像素已计算。我认为webkit在px中报告尺寸,而不管它们通过JavaScript调用时如何设置。
You may have to use JavaScript to change the percentage value to pixels after it has been calculated. I think webkit reports dimensions in px regardless of how they were set when called via JavaScript.
这篇关于将像素转换为百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文