在 Internet Explorer 中使用 jQuery 读取 CSS3 属性

发布于 2025-01-07 06:23:57 字数 322 浏览 0 评论 0原文

我正在制作一个带有 jQ​​uery 后备功能的 HTML5 幻灯片,但遇到了一些问题。我需要在所有浏览器中找到 #containtertransition-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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你与昨日 2025-01-14 06:23:57

Internet Explorer 似乎不支持转换属性。
看看这个:

div
{
transition-property: width;
transition-duration: 1s;
transition-timing-function: linear;
transition-delay: 2s;
/* Firefox 4 */
-moz-transition-property:width;
-moz-transition-duration:1s;
-moz-transition-timing-function:linear;
-moz-transition-delay:2s;
/* Safari and Chrome */
-webkit-transition-property:width;
-webkit-transition-duration:1s;
-webkit-transition-timing-function:linear;
-webkit-transition-delay:2s;
/* Opera */
-o-transition-property:width;
-o-transition-duration:1s;
-o-transition-timing-function:linear;
-o-transition-delay:2s;
}

来自:http://www.w3schools.com/css3/css3_transitions.asp

但我刚刚发现了这个:

-ms-transition-property,
-ms-transition-duration, 
-ms-transition-timing-function, 
-ms-transition-delay

来自 http://msdn.microsoft.com/en-us/library/windows/apps/hh466382.aspx

Internet Explorer doesn't seem support the transition property.
Look at this :

div
{
transition-property: width;
transition-duration: 1s;
transition-timing-function: linear;
transition-delay: 2s;
/* Firefox 4 */
-moz-transition-property:width;
-moz-transition-duration:1s;
-moz-transition-timing-function:linear;
-moz-transition-delay:2s;
/* Safari and Chrome */
-webkit-transition-property:width;
-webkit-transition-duration:1s;
-webkit-transition-timing-function:linear;
-webkit-transition-delay:2s;
/* Opera */
-o-transition-property:width;
-o-transition-duration:1s;
-o-transition-timing-function:linear;
-o-transition-delay:2s;
}

From : http://www.w3schools.com/css3/css3_transitions.asp

But I've just found this :

-ms-transition-property,
-ms-transition-duration, 
-ms-transition-timing-function, 
-ms-transition-delay

From http://msdn.microsoft.com/en-us/library/windows/apps/hh466382.aspx

千年*琉璃梦 2025-01-14 06:23:57

我不久前在这里写过这个: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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文