Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why css "all: unset" works weirdly in Safari browser for MacOS?

So basically I made this situation, the parent has the css all: unset.

Then I notice when I use Safari(Version 12.1.1 (14607.2.6.1.1)) all the children of it color only can be effected by * block, not even inline or !important.

But only color behaves that way, as you can see the background-color is using it's own property.

But it works fine in Chrome, is it a glitch in safari or I did something wrong? And how can I fix it in Safari?

* {
  color: red;                   /* Text color is using this one */
  background-color: pink;
}

.Parent {
  all: unset;
}

.Child {
  color: blue;
  background-color: yellow;     /* Background color is using this one */
}
<div class="Parent">
  <div class="Child">Some Text</div>
</div>
  • Expected result(Chrome) enter image description here

  • Wrong result(Safari Version 12.1.1 (14607.2.6.1.1)) enter image description here

like image 766
Hao Wu Avatar asked May 22 '19 03:05

Hao Wu


People also ask

How do I fix Safari CSS issues?

Displaying properties in Safari There is a CSS appearance property used to display an element using a platform-native styling based on the users' operating system's theme. To make it work on Safari, we must set the appearance property to its "none" value. Also, use -WebKit- and -Moz- vendor prefixes.

What CSS does Safari not support?

The visibility:collapse CSS property is not supported by Safari for table columns, and not supported on older browsers.

Does CSS work in Safari?

Does Safari support CSS? Safari does support CSS and is compatible with most modern browsers. However, because it's not as popular as Chrome or Firefox, users tend to ignore it.


1 Answers

Safari uses the special property -webkit-text-fill-color. If you use that, the color works:

* {
  color: red;                   /* Text color is using this one */
  background-color: pink;
  -webkit-text-fill-color: red;
}

.Parent {
  all: unset;
}

.Child {
  color: blue;
  background-color: yellow;     /* Background color is using this one */
  -webkit-text-fill-color: blue;
}
<div class="Parent">
  <div class="Child">Some Text</div>
</div>

@ Dan Fabulich commented the bug for this below:
https://bugs.webkit.org/show_bug.cgi?id=158782

like image 187
Anonymous Avatar answered Sep 22 '22 09:09

Anonymous