html - CSS 样式表错误 - DOMException 无法在 css.stylesheet 上插入规则

标签 html css css-selectors domexception

我的 css 样式表上有这个疯狂的错误 - 在所有浏览器上进行了测试,但不起作用。这是错误:

VM2952 LiveUpdateTools.js:688 Uncaught DOMException: Failed to execute 'insertRule' on 'CSSStyleSheet': Failed to parse the rule '.about #2015-marker-label { top: calc(86vh - 6px); }'.
at Object.insertRule (http://127.0.0.1:59944/static/files/LiveUpdateTools.js:688:12)
at http://127.0.0.1:59944/static/files/deviceClientScript.js:390:23

这是 css 样式表:

.about .marker-text {
    left: calc(50% + 28px);
    position: absolute;
    color: black;
    font-family: Lato;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.5px;
}

.about #2000-marker-label {
    top: calc(12vh - 6px);
}

.about #2005-marker-label {
    top: calc(32vh - 6px);
}

.about #2010-marker-label {
    top: calc(52vh - 6px);
}

.about #2015-marker-label {
    top: calc(86vh - 6px);
}

最后是 HTML 标记:

<label id="2000-marker-label" class="marker-text">2000</label>
<label id="2005-marker-label" class="marker-text">2005</label>
<label id="2010-marker-label" class="marker-text">2010</label>
<label id="2015-marker-label" class="marker-text">2015</label>

body 元素上有一个名为“about”的类,因此所有样式表选择器上都有 .about。 未设置 top 属性,我认为这是错误造成的。这不像我在这里做任何疯狂的事情,我用谷歌搜索错误并得到 2 个过时的结果,说这是 chrome 中的一个问题。 无论如何,感谢您能给我的任何帮助,我很感激。

最佳答案

错误已修复 - 不知道标识符不能以数字开头!奇怪的……

关于html - CSS 样式表错误 - DOMException 无法在 css.stylesheet 上插入规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46017395/

相关文章:

html - Z-index 下拉菜单问题

css - 试图在 Squarespace 中粘贴视频?这可能吗?

html - CSS 选择器选择部分 div 类名

html - css backface 属性是否在最新的 Chrome 中被破坏了?

html - 在固定位置写入文本的问题

javascript - 这足以防止我的网站上出现 xss 吗?

css - Sass 的@use 特性

sass - 在 Sass 中修改选择器的中间部分(添加/删除类等)

css - css中的级联规则问题

html - 下拉菜单正确吗?