css - 如何在 Internet Explorer 中正确使用 CSSStyleSheet.insertRule()?

标签 css internet-explorer-11

我在使用此代码的 Internet Explorer 11 中遇到“IndexSizeError”错误:

var style = document.createElement('style');
document.head.appendChild(style);
style.sheet.insertRule('td {overflow: visible}');

根据 https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule索引参数是可选的。

最佳答案

在 IE11 中,如果我添加索引参数,错误将得到修复:

var style = document.createElement('style');
document.head.appendChild(style);
style.sheet.insertRule('td {overflow: visible}', 0);

相关:How to use CSSStyleSheet.insertRule() properly?

关于css - 如何在 Internet Explorer 中正确使用 CSSStyleSheet.insertRule()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58695205/

相关文章:

javascript - 最初选择但不滑动时出现的 JQuery slider - IE9

css - 如何使用 Bootstrap 创建水平节点分支?

css - Bootstrap panel-footer with button pull-right

javascript - 将一个圆DIV分成四个扇形DIV

CSS:如何为事件链接添加向下箭头

javascript - 在新选项卡中打开但未与父选项卡分组

javascript - 当我的 Vue 应用程序无法在 IE11 上呈现时,如何显示免责声明屏幕?

internet-explorer - 即使启用增强保护模式,IE 选项卡也不会在 64 位模式下运行

javascript - 如何从 IE 11 中的事件获取父元素的属性?

javascript - 消极的向后看。如何修复正则表达式以在 IE11、Safary 中使用它?