javascript - 设置自定义样式属性在 IE11 中不起作用
问题描述
我有这个简单的 Javascript 代码来更改自定义 CSS 属性
var root = document.documentElement;
root.style.setProperty("--custom-bg", "#4f5357");
这在 Firefox Google Chrome 中运行良好,但在 IE 11 中不起作用,也尝试过
root['--custom-bg'] = "#4f5357";
root.attr("--custom-bg", "#4f5357");
root.style['--custom-bg'] = "#4f5357";
他们都没有工作。
解决方案
IE11不支持 css 自定义属性,因此不支持这种setProperty
方法。
查看这个css-vars-ponyfill,它旨在添加基本支持。
推荐阅读
- javascript - 图片上传如何与 Dropzone.js 配合使用?
- swagger - 在 Swagger api yaml 中将属性值从一个模式传递到另一个模式
- java - 如何在 JAVA 16.0 中发送 HTTP 请求
- php - wkhtmltopdf / phpwrapper 做内部 URL
- r - 转换系列并根据原始列命名
- java - 在java中从键盘输入价格
- python - Postman Django CSRF 请求 get_auth_token 路由时出错
- node.js - 对猫鼬中的值求和
- python - python中的数据矩阵GS1
- django - 在 django 中单击按钮获取输入值