-webkit-linear-gradient w/ angle reversed in Safari

自闭症网瘾萝莉.ら 提交于 2019-12-11 05:00:51

问题


On my way to finding a CSS solution to have an evenly colored element with angled beginning to avoid images I stumbled across this simple example: http://dabblet.com/gist/1780333 . This one is working fine, even in IE of the latest, only Safari is reversing it completely, putting it to the end instead of the beginning AND turning the angle partly, at least in my live site it's not consistent. I have, of course, the same values for all browser versions.

Anybody an idea why it is so and what one can do - or an alternative solution without images to come up with an angled left side of an element?


回答1:


I think you found a bug! Or at least Safari is interpreting the angles differently.

This isn't surprising as until pretty recently Safari used the -webkit-gradient syntax which is much less flexible. For example, it doesn't allow angles.

Still you can solve your problem by including the old syntax, which still works:

  background: -webkit-gradient(linear, 10% 100%, 0% 0%, color-stop(80%, #000000), color-stop(80%, transparent));
  background: -webkit-linear-gradient(60% 100%, #000000 80%, transparent 80%);
  background: -moz-linear-gradient(60% 100%, #000000 80%, transparent 80%);
  background: -o-linear-gradient(60% 100%, #000000 80%, transparent 80%);
  background: linear-gradient(60% 100%, #000000 80%, transparent 80%);

Demo




回答2:


This isn't a bug - there were quite a few changes between the Working Draft and the Candidate Recommendation for the gradient syntax, one of which is the angle of the gradient:

From the IE Blog. Hence the unprefixed version requires a different deg value to the prefixed versions. The CR is much more logical (to me at least), with 0deg being a gradient line pointing to the top and increasing in a clockwise direction.



来源:https://stackoverflow.com/questions/15720299/webkit-linear-gradient-w-angle-reversed-in-safari

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!