I'm learning how to use CSS gradients.
My problem is with top to bottom gradients. You can just see the "stops" in the color changing.
This is my CSS code
#header {
width:1000px;
height:250px;
background:-moz-linear-gradient(top, #BF7A30 30%, #EDD599);
background:-webkit-linear-gradient(top, #BF7A30 30%, #EDD599);
}
Is there a way to smooth out the stops in top to bottom gradients? (this, to my eye, isn't very visible in left to right or right to left gradients)
To create a radial gradient that repeats so as to fill its container, use the repeating-radial-gradient() function instead. Because <gradient> s belong to the <image> data type, they can only be used where <image> s can be used.
You can choose between three types of gradients: linear (created with the linear-gradient() function), radial (created with the radial-gradient() function), and conic (created with the conic-gradient() function).
The linear-gradient() CSS function creates an image consisting of a progressive transition between two or more colors along a straight line. Its result is an object of the <gradient> data type, which is a special kind of <image> .
CSS has two types of gradients: Linear gradient: It goes down/up/left/right/diagonally and makes smooth transitions of colors. To make a linear transition you first have to choose two color stops. Color stops are the color among which you want to make the transitions.
The main cause of this bending effect is actually the linear blending of colors, which is not as harmonious to the human eye.
Andreas Larsen has written a pretty elaborate article on css-tricks.com (2017). https://css-tricks.com/easing-linear-gradients/
It describes a concept of non-linear gradients by defining multiple color stops approximating a clothoid curve.
Would result in something like this (.gradient-clothoid):
.gradient-wrp {
display: flex;
}
.header {
width: 100%;
height: 250px;
flex: 0 0 none;
}
.gradient-linear {
background-image: linear-gradient(#bf7a30 30%, #edd599);
}
.gradient-smooth {
background-image: linear-gradient(#bf7a30 25%, 75%, #edd599);
}
.gradient-clothoid {
background-image: linear-gradient(
rgba(191, 122, 48, 1) 0%,
rgba(191, 122, 48, 0.3) 50%,
rgba(191, 122, 48, 0.15) 65%,
rgba(191, 122, 48, 0.075) 75.5%,
rgba(191, 122, 48, 0.037) 82.85%,
rgba(191, 122, 48, 0.019) 88%,
rgba(191, 122, 48, 0) 100%
);
}
<div class="gradient-wrp">
<div class="header gradient-linear"></div>
<div class="header gradient-smooth"></div>
<div class="header gradient-clothoid"></div>
</div>
This concept is also known as "scrim".
IMHO not so well suited for "starting" color stops like the original example:
I actually prefer Amelia Bellamy-Royds’ proposal (article down below in the comments) using a (well supported) gradient smoothing by adding stop without color definition like so:
.gradient-smooth{
background-image:linear-gradient(#BF7A30 25%, 75%, #EDD599);
}
This will smooth the gradient between 25% and 75% to the bottom spline based and not linear.
.gradient-linear{
background-image:linear-gradient(#BF7A30 30%, #EDD599);
}
As @nighthawk2534 mentioned, adding more colors to the gradient is the way to go. Obviously, those have to be "right" colors.
I don't know color theory enough, but stumbled upon a great tool for that: https://mycolor.space/gradient
For your example it gives:
background-image: linear-gradient(to right top, #bf7a30, #ca9148, #d5a861, #e1bf7d, #edd599);
Which looks like that: image
(I know this thread is very old, but still may be helpful)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With