html - 为什么 CSS 规则不适用于真实的 HTML 页面,但适用于 JSFiddle?
问题描述
在我的网站中,我编写了以下 CSS 规则:
.holder-features ul li:before {
content: "";
background-image: url(/image/icons/check.svg);
display: block;
width: 10px;
height: 10px;
background-position: center center;
background-size: contain;
background-repeat: no-repeat;
}
然后在网页http://www.sybase-recovery.com/outlook-repair/中,单击“Features”选项卡并选择其中一个列表项时,我使用 DevTools 检查元素,但找不到规则.holder-features ul li:before被应用。
然后我将清单和 CSS 代码复制到 JSFiddle,然后简化清单代码,然后重试,但发现 CSS 规则确实适用。见https://jsfiddle.net/alanccw/9oucLfrx/10/
为什么?
解决方案
该问题是由您在单个 css 中注释多个并导致错误的错字引起的
考虑将其更改为
/*
.holder-features ul li:before {
display: none;
font-style: normal;
font-variant: normal;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
font-family: "Font Awesome 5 Free";
font-weight: 900;
content: "\f00c";
content: url("/images/icons/check.svg");
}
*/
更改后,您将看到:before
您所期望的
推荐阅读
- r - 如何从网页的不同超链接中提取数据
- javascript - 在 div 上添加 OnClick 事件
- firebase - 为什么我在 Firestore(App 引擎)中有这些奇怪的配额数字?
- elasticsearch - 如何从分数计算中取出(别名字段的长度)
- css - 桌面上的 2 列 移动设备上的 1 列,带有 flexbox
- python - 使用python从json格式中获取指定数据?
- android - Chrome 自定义选项卡链接不会启动应用程序,但移动版 chrome 浏览器会
- java - BeanCreationException:在将 eureka 服务器添加到 Spring Boot 应用程序时抛出名为“simpleMeterRegistry”的 bean 创建错误
- python - 如何仅将推文的文本获取到 json 文件中
- java - 为什么 ThumbnailUtils.createVideoThumbnail() 从图库中获取视频时返回 null