I have a situation that is as follows, I have linear-gradiente
in an element, however I want the first and last part of this gradient to have 100px of a single color, and the middle of it is always 100% complete by a another color.
To make it clear, I made this image. Note that using 10% 90% 10% , if the element is of widths other than the width of the left and right "column" will change proportion.
WhatIwantedwas100px100%100px,withafixedvaluethatshouldnotchangeiftheelementiswiderornarrower...
ThenhowwouldImergevaluesinPX
and%
intothegradientsoastohavethefirstandlastpartwithvaluesinPX
thatwillnotvaryaccordingtowidth,butwiththemiddleoccupyingtherestofspace?
HereisthecodeIusedintheexamples:
.box {
width: 50%;
height: 100px;
border: 1px solid #000;
background-image: linear-gradient(to right, red 10%, blue 10%, blue 90%, red 90%);
}
.box:nth-child(2) {
width: 25%;
}
<div class="box"></div>
<div class="box"></div>