【发布时间】:2022-01-14 07:42:51
【问题描述】:
我正在建立一个网站,除了 iPhone 上的链接外,移动设备中的所有样式都可以正常工作。我已经尝试了这个线程中的解决方案:How do I remove the blue styling of telephone numbers on iPhone/iOS?
我试过这个CSS:
a[href^="tel"],
span[href^="tel"] {
color: inherit !important;
text-decoration: none !important;
font-size: inherit !important;
font-family: inherit !important;
font-weight: inherit !important;
line-height: inherit !important;
}
还有这个CSS:
a[x-apple-data-detectors],
span[x-apple-data-detectors] {
color: inherit !important;
text-decoration: none !important;
font-size: inherit !important;
font-family: inherit !important;
font-weight: inherit !important;
line-height: inherit !important;
}
以上都不适合我。关于如何使用纯 CSS 解决此问题以便我的所有网页都继承样式的任何建议?
更新解决方案
接受的答案将改变所有<span> / <a> 元素的默认行为。相反,您应该在元素上使用 id 或 class 设置样式。示例可能如下所示:
.lnd-header-button__text{
all: initial;
}
.lnd-header-button__text * {
all: unset;
}
【问题讨论】:
-
不包括当前标记 (HTML) 和 CSS 赋予链接颜色的内容(您可以通过检查元素找到此内容),邀请解决方案/答案可能会影响比您更多的元素想要样式和解决方案对 CSS 应用比必要的更高的特异性。这使您更难以将后续的 CSS 声明应用于您的元素。
-
我更新了帖子,希望这是您正在寻找的内容,感谢您的解释,我明白您的意思。 @tao