在 Internet Explorer 中使用 jQuery 读取 CSS3 属性
我正在制作一个带有 jQuery 后备功能的 HTML5 幻灯片,但遇到了一些问题。我需要在所有浏览器中找到 #containter
的 transition-duration
值,尤其是 Internet Explorer,因为没有版本支持 CSS3 过渡。
我正在使用 jQuery 来执行此操作,但它在 IE 中不起作用:
$('#container').css('transition-duration')
有什么方法可以做到这?我认为问题是 IE 甚至不加载 CSS 值,因为它不受支持。
I'm working on an HTML5 slideshow with a jQuery fallback, and I'm having a bit of an issue. I need to find the value of transition-duration
of #containter
in all browsers, especially Internet Explorer, since no version supports CSS3 transitions.
I'm using this bit of jQuery to do this, but it doesn't work in IE:
$('#container').css('transition-duration')
Is there any way to do this? I think the issue is that IE doesn't even load the CSS value since it's not supported.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Internet Explorer 似乎不支持转换属性。
看看这个:
来自:http://www.w3schools.com/css3/css3_transitions.asp
但我刚刚发现了这个:
来自 http://msdn.microsoft.com/en-us/library/windows/apps/hh466382.aspx
Internet Explorer doesn't seem support the transition property.
Look at this :
From : http://www.w3schools.com/css3/css3_transitions.asp
But I've just found this :
From http://msdn.microsoft.com/en-us/library/windows/apps/hh466382.aspx
我不久前在这里写过这个:http://focalstrategy.com/blog/2010/08/howto/an-animated-image-slider-that-works-in-internet-explorer/ 。
我的技术是使用 JS 触发转换,这样就可以轻松地在 JS 中设置计时值。
如果您想读取属性,则需要通过 XHR 加载样式表,然后解析它。这是一个令人痛苦的事情,因为为了使其健壮,您需要解析页面的 html 以获取所有样式表,并确保观察任何媒体查询和 @import 语句。您还需要确保遵循级联并考虑特异性。
我会按照我的方式来做,它更加灵活,并且仍然具有 CSS3 过渡的所有优点。
I wrote about this a while ago here: http://focalstrategy.com/blog/2010/08/howto/an-animated-image-slider-that-works-in-internet-explorer/ .
My technique was to trigger the transitions using JS, making it easy to just set the timing values in your JS.
If you want to read the properties, you'll need to load the stylesheet via an XHR, then parse it. That is a pain in the ass for this as to make it robust you'll need to parse the html of the page to get all the stylesheets, and make sure you observe any media queries and @import statements. You'll also need to make sure you follow the cascade and take specitivity into account.
I'd do it the way I do it, it's much more flexible, and still has all the benefits of CSS3 transitions.