Reputation: 4498
A CSS linear gradient background element has fuzzy transitions between colours even when the stops are at the same spot.
I have an element with the background defined like so:
background:linear-gradient(to right,
blue, blue 10%,
red 10%, red 30%,
yellow 30%, yellow 40%,
green 40%, green 50%,
black 50%
);
In Firefox, the transitions between the colours are fuzzy. If I use a repeating-linear-gradient
the edges are crisp. Both are crisp in Chrome.
I have an example pen here: https://codepen.io/anon/pen/rPVWZE?editors=1100#0
Any ideas on how to fix this?
Upvotes: 0
Views: 354
Reputation: 4857
Here the effect on FF. I drew some pixels to show zoom level:
A workaround:
.linear{
height:100px;
background-image:
linear-gradient(to right, blue 0, blue 100px),
linear-gradient(to right, red 0, red 100px),
linear-gradient(to right, yellow 0, yellow 100px);
background-size:
100px 100px,
100px 100px,
100px 100px;
background-position:
0 0,
100px 0,
200px 0;
background-repeat: no-repeat;
}
<div class = "linear"></div>
Upvotes: 2