html - Safari: `all: unset;` 添加大量 css 规则

标签 html css safari webkit

我有一些非常简单的 HTML,可以在 Chrome 上完美运行,但在 Safari 上却不能。根据网络检查员的说法,我的跨度应该显示绿色文本。但是它显示为黑色。

what it looks like

如您所见,名字“John”显示为黑色。然而,根据网络检查员的说法,它应该是绿色的。

web inspector

经过一番修改,我发现问题出在我对 all: unset; 的使用上。 。由于某种原因,当使用all: unset;时在 <span> 的父元素之一中,计算出的 CSS 规则来自:

box-sizing: border-box;
color: rgb(9, 112, 19);
display: inline;
font-family: Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 13px;
height: auto;
line-height: 25px;
pointer-events: auto;
width: auto;

-webkit-border-horizontal-spacing: 0px;
-webkit-border-vertical-spacing: 0px;
-webkit-box-direction: normal;
-webkit-cursor-visibility: auto;
-webkit-font-kerning: auto;
-webkit-font-smoothing: auto;
-webkit-hyphenate-character: auto;
-webkit-hyphenate-limit-after: auto;
-webkit-hyphenate-limit-before: auto;
-webkit-hyphenate-limit-lines: no-limit;
-webkit-hyphens: manual;
-webkit-line-align: none;
-webkit-line-box-contain: block inline replaced;
-webkit-line-grid: none;
-webkit-line-snap: none;
-webkit-locale: en-US;
-webkit-nbsp-mode: normal;
-webkit-print-color-adjust: economy;
-webkit-rtl-ordering: logical;
-webkit-text-combine: none;
-webkit-text-decoration-line: none;
-webkit-text-decorations-in-effect: none;
-webkit-text-emphasis-color: rgb(0, 0, 0);
-webkit-text-emphasis-position: over right;
-webkit-text-emphasis-style: none;
-webkit-text-fill-color: rgb(0, 0, 0);
-webkit-text-orientation: mixed;
-webkit-text-security: none;
-webkit-text-size-adjust: auto;
-webkit-text-stroke-color: rgb(0, 0, 0);
-webkit-text-stroke-width: 0px;
-webkit-user-modify: read-only;
-webkit-user-select: text;
border-collapse: separate;
box-sizing: border-box;
caption-side: top;
clip-rule: nonzero;
color: rgb(9, 112, 19);
color-interpolation: sRGB;
color-interpolation-filters: linearRGB;
color-rendering: auto;
cursor: auto;
display: inline;
empty-cells: show;
fill: rgb(0, 0, 0);
fill-opacity: 1;
fill-rule: nonzero;
font-family: Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
font-optical-sizing: auto;
font-size: 13px;
font-style: normal;
font-synthesis: style weight small-caps;
font-variant-numeric: normal;
font-weight: normal;
glyph-orientation-horizontal: 0deg;
glyph-orientation-vertical: auto;
hanging-punctuation: none;
height: auto;
image-rendering: auto;
kerning: 0;
letter-spacing: normal;
line-height: 25px;
list-style-image: none;
list-style-position: outside;
list-style-type: disc;
marker-end: none;
marker-mid: none;
marker-start: none;
orphans: auto;
overflow-wrap: normal;
pointer-events: auto;
resize: none;
shape-rendering: auto;
stroke: none;
stroke-dasharray: none;
stroke-dashoffset: 0px;
stroke-linecap: butt;
stroke-linejoin: miter;
stroke-miterlimit: 4;
stroke-opacity: 1;
stroke-width: 1px;
tab-size: 8;
text-align: start;
text-anchor: start;
text-decoration: none;
text-indent: 0px;
text-rendering: auto;
text-shadow: none;
text-transform: none;
visibility: visible;
white-space: normal;
widows: auto;
width: auto;
word-break: normal;
word-spacing: 0px;
word-wrap: normal;
writing-mode: horizontal-tb;

这是不希望的,因为使用 all: unset; 的目的是是删除该元素的所有现有 CSS 规则。原因是它覆盖在现有网站之上,因此可以从底层网站继承 CSS 规则。我用all: unset;以避免底层网站 CSS 规则干扰此应用程序。

如果我简单地添加-webkit-text-fill-color: #097013;根据我的 CSS 规则,它将按预期工作。 但我不明白为什么要添加 all: unset;添加了如此多的 CSS 规则,而其本意是删除它们。

最佳答案

在研究了“all”规则的“unset”属性如何工作之后,我对它的假设似乎是错误的。 According to W3 :

unset - Changes all the properties applied to the element or the element's parent to their parent value if they are inheritable or to their initial value if not

关于html - Safari: `all: unset;` 添加大量 css 规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56659485/

相关文章:

JavaScript Sprite 表用于普通和视网膜屏幕

具有可滚动全尺寸图像的 CSS 定位

jquery - 在 ListView 中更改箭头的圆盘颜色

html - 输入越过 div

iphone - 如何在用户图标单击时直接打开具有给定 url 的浏览器?

ios - Pocket 如何将他们保存的消息放在 Safari 之上

css - Safari 6 Inspector 是否显示 CSS 继承链?

jquery - jquery 中的 addClass() removeClass() 问题

php - 动态菜单权限不起作用

html - Bootstrap - 使卡片水平滚动