简体   繁体   English

使用js将CSS“ display:none”值替换为“ display:flex”

[英]replacing css “display:none” value with "display:flex using js

i'm attempting to replace a css value "display:none" defined on a div by a "display:flex" using js property .css(). 我正在尝试使用js属性.css()将div上定义的CSS值“ display:none”替换为“ display:flex”。 When doing so, safari on Ipad ignores the js instruction (i used the prefixes for cross browser compatibility + tried css !important) and instead it applies "display:block" which is the user agent style defaulted value (i have a reset.css in place as well)...it ends up not giving what i'm looking for. 这样做时, Ipad上的safari会忽略js指令(我使用了跨浏览器兼容性的前缀+尝试过css!important),而是应用了“ display:block”,这是用户代理样式的默认值(我有reset.css到位)...它最终没有给出我想要的东西。 However the issue does not occur on desktop browsers. 但是,在桌面浏览器上不会发生此问题。 Any tips to override this defaulted value on Ipad please? 有什么提示可以覆盖Ipad上的默认值?

try as below create a CSS class 尝试如下创建一个CSS类

.temp{
display:flex!important;
}

add that class dynamically to the element using addClass function in jquery 使用jquery中的addClass函数将该类动态添加到元素中

$(selector).addClass('temp');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM