0
0
SASSmarkup~10 mins

Mix function for blending in SASS - Browser Rendering Trace

Choose your learning style9 modes available
Render Flow - Mix function for blending
[Read SCSS file] -> [Parse variables and functions] -> [Evaluate mix() function] -> [Calculate blended color] -> [Generate CSS with blended color] -> [Browser applies CSS color]
The browser reads the SCSS file, the mix() function blends two colors by calculating a weighted average, then outputs CSS with the new color which the browser renders.
Render Steps - 5 Steps
Code Added:$color1: #ff0000;
Before
[ ] (empty box, no color)
After
[ ] (still empty, no visible change)
Defining a color variable does not change the visual output yet.
🔧 Browser Action:Parse variable, no repaint triggered
Code Sample
A square box with background color blended evenly between red and blue, resulting in purple.
SASS
<div class="box">Blended Color Box</div>
SASS
$color1: #ff0000;
$color2: #0000ff;
$blend: mix($color1, $color2, 50%);
.box {
  width: 10rem;
  height: 10rem;
  background-color: $blend;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  border-radius: 0.5rem;
}
Render Quiz - 3 Questions
Test your understanding
After applying step 4, what color fills the box?
APurple (blend of red and blue)
BRed (#ff0000)
CBlue (#0000ff)
DTransparent (no color)
Common Confusions - 2 Topics
Why doesn't changing the mix() weight to 0% show the first color?
At 0% weight, mix() returns the second color fully, so the box shows the second color, not the first.
💡 Remember: mix(color1, color2, 0%) equals color2; 100% equals color1.
Why does the box color look purple and not red or blue?
Because mix() blends red and blue evenly at 50%, the result is purple, a mix of both colors.
💡 Mix blends colors proportionally; equal parts create a new color in between.
Property Reference
PropertyValue AppliedEffect on ColorCommon Use
mix()mix($color1, $color2, $weight)Blends two colors by weight percentageCreate intermediate colors for gradients or themes
background-colorcolor valueSets background fill color of elementVisual background styling
width / heightlength units (rem)Defines size of element boxControl element dimensions
displayflexEnables flex container for alignmentCenter content easily
align-itemscenterVertically centers flex itemsVertical alignment
justify-contentcenterHorizontally centers flex itemsHorizontal alignment
colorwhiteSets text colorText visibility on backgrounds
border-radius0.5remRounds corners of boxSoftens box edges visually
Concept Snapshot
mix($color1, $color2, $weight) blends two colors by weight percentage. Weight 0% returns second color; 100% returns first color. Use mix() to create smooth color transitions. Apply blended color with background-color property. Flexbox centers content easily inside containers. Rounded corners soften box edges visually.