gpt4 book ai didi

css - CSS 样式表中不允许使用任何字符吗?

转载 作者:太空宇宙 更新时间:2023-11-04 05:19:22 25 4
gpt4 key购买 nike

长话短说,我在 javascript 变量中放置了一堆 css 样式,然后在 head 元素中动态注入(inject) css 样式节点。我想使用一个字符对循环容器 .someContainer 进行编码,然后在我的 javascript 中进行搜索和替换。这会减少我的总 css 字节数。所以我试图找出我永远不会在样式表中遇到的 Angular 色。我想不出我什么时候在 css 中看到 ~ 字符并认为它可能是一个很好的候选者。有人知道吗?

最佳答案

对于 two reasons 波浪号是一个糟糕的调用:

E[foo~="bar"]
an E element whose "foo" attribute value is a list of whitespace-separated values, one of which is exactly equal to "bar"

E ~ F
an F element preceded by an E element

您不能保证不会因为 :before and :after pseudo-elements: 而使用其他任何东西

span:before {
content: "anything is possible in here (or at zombo.com)";
}

您可能会遇到与 url() 类似的问题.你也许可以逃脱 < (但不是 > )但你仍然有 content :before 的问题和 :after .

您最好将所有设置都设置为对样式表使用 gzip 压缩,并可能将其卸载到 CDN。

关于css - CSS 样式表中不允许使用任何字符吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7035960/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com