使用jQuery为多个浏览器设置flexbox显示? [英] Setting flexbox display with jquery for multiple browsers?

查看:132
本文介绍了使用jQuery为多个浏览器设置flexbox显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有点麻烦。我需要从显示切换:none显示:flex,显示:flex-box,并显示:-ms-flexbox,但它似乎打破了我的代码..这是我到目前为止:

  $(elem).css({'display':'flex','display':'-webkit-flex','display': '-MS-Flexbox的'}); 

尽管如此:

<$ p $ $ {code $(elem).css({'display':'flex'})

我需要另外两个Safari和IE10。有没有什么方法来写这个,以便它不会破坏我的代码? Jquery似乎对这个语法感到困惑。

解决方案

我刚才遇到同样的问题。问题是你不能在同一个对象中指定 display 的多个值,因为你只能有一个名为的对象成员显示

如果您不担心意外删除任何其他元素级别的样式,则可以采用以下方法之一:

  $(elem).attr('style','display:-webkit-flex; display:flex'); 

(当然,如果需要,还可以为IE10添加额外的一个)。 b
$ b

对不起,这么晚了,也许会帮助其他人。

having a bit of trouble. I need to have something switch from display: none to display: flex, display: flex-box, and display: -ms-flexbox but it seems to be breaking my code.. Here's what I have so far:

$(elem).css({'display': 'flex', 'display': '-webkit-flex', 'display':'-ms-flexbox'});

and while this works:

$(elem).css({'display': 'flex'})

I need to have the other two for safari and IE10. Is there any way of writing this so that it doesn't break my code? Jquery seems confused by this syntax.

解决方案

I just ran across the same issue. The problem is that you can't specify multiple values of display in the same object, because you can only have one object member called display.

If you're not worried about accidentally removing any other element-level styles, this is one way around:

$(elem).attr('style', 'display: -webkit-flex; display: flex');

(and of course add the extra one for IE10 if you need to).

Sorry to be so late to the party, but maybe it will help others.

这篇关于使用jQuery为多个浏览器设置flexbox显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆