Skip to content
Justice Tech School

Opacity and Box Shadow

opacity runs from 0 (invisible) to 1 (solid) and affects the element and everything inside it. To make only the background transparent, use an rgba or hsl colour with alpha instead.

box-shadow takes x offset, y offset, blur, optional spread and a colour. Add the inset keyword for an inner shadow, and separate several shadows with commas.

Example
<style>
  .stack div { display: inline-block; width: 90px; height: 90px; margin: 12px; background: #7c3aed; border-radius: 10px; color: white; text-align: center; line-height: 90px; }
  .half { opacity: 0.5; }
  .raise { box-shadow: 0 8px 18px rgba(0,0,0,0.3); }
  .inner { box-shadow: inset 0 0 14px rgba(0,0,0,0.6); }
</style>
<div class="stack">
  <div class="half">0.5</div>
  <div class="raise">Shadow</div>
  <div class="inner">Inset</div>
</div>

Exercise

Make the element half see-through.

.ghost {
  : 0.5;
}

Quiz Test

What does opacity: 0 do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.