Reputation: 61
How do I map out 6 different colors from top to bottom on the y-axis co-ordinates 1, 2, 3, 4, 5 and 6 and those colors take up 1 px each and have a 7th color take up the rest of the div? I have tried this but it does not work:
background-image: linear-gradient(to bottom, #e2e2e2 0%, #e8e8e8 2px, #efefef 3px, #f4f4f4 4px, #f7f7f7 5px, #f8f8f8 6px, #f9f9f9 100%);
Upvotes: 3
Views: 4135
Reputation: 4902
There you go
#grad1 {
height: 200px;
background: red; /* For browsers that do not support gradients */
background: -webkit-linear-gradient(bottom, orange , yellow, green, cyan, blue, violet); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(bottom, orange, yellow, green, cyan, blue, violet); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(bottom, orange, yellow, green, cyan, blue, violet); /* For Firefox 3.6 to 15 */
background: linear-gradient(to bottom, orange , yellow, green, cyan, blue, violet); /* Standard syntax (must be last) */
}
<div id="grad1"></div>
Upvotes: 1
Reputation: 272590
Try like below:
html {
min-height:100%;
background-image:
linear-gradient(to bottom,
orange 0 10px,
red 0 20px,
purple 0 30px,
green 0 40px,
#f7f7f7 0 50px,
blue 0 60px,
yellow 0);
}
Or like this if you want a fading transition
html {
min-height:100%;
background-image:
linear-gradient(to bottom,
orange 10px,
red 20px,
purple 30px,
green 40px,
#f7f7f7 50px,
blue 60px,
yellow 0);
}
Another idea with multiple gradient:
html {
min-height:100%;
background:
linear-gradient(to bottom,
orange ,
red ,
purple ,
green ,
#f7f7f7 ,
blue ) top/100% 25% no-repeat, /* 25% = height */
yellow;
}
Upvotes: 5
Reputation: 7949
try this:
div {
background: #466368;
background: linear-gradient(to right, #e2e2e2 40px, #f8f8f8 50%, #e8e8e8 10%, #293f50 );
border-radius: 6px;
height: 120px;
}
<div></div>
Upvotes: 0
Reputation: 33804
I think this does what the question is asking - the sizes were edited to make the effect discernible on-screen and admittedly the first example is very garish
.graded{
background: linear-gradient(
yellow 0%,
blue 10px,
red 20px,
green 30px,
pink 40px,
orange 50px,
#f9f9f9 60px,
#f9f9f9 100%
);
}
.re-graded{
background: linear-gradient(
#e2e2e2 0%,
#e8e8e8 10px,
#efefef 20px,
#f4f4f4 30px,
#f7f7f7 40px,
#f8f8f8 50px,
#f9f9f9 60px,
#f9f9f9 100%
)
}
div{
width: 100%;
height:10rem;
border:1px solid black;
}
<div class='graded'>obvious</div>
<div class='re-graded'>subtle</div>
Upvotes: 0