On day 9 I’ve talked about the inset shorthand properties inset, inset-inline, and inset-block. I don’t believe that I will need those often, but inset can come in handy when you want one element to fill another element entirely.

If you have an outer element and an inner element and you want the inner element to fill its parent, you can use absolute positioning and set top, right, bottom, and left to 0.

<div class="outer">
  <div class="inner">
  </div>
</div>
.outer {
  border: 10px solid hotpink;
  position: relative;
  width: 7rem;
  height: 7rem;
}

.inner {
  background: aqua;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

Instead, you could also just set inset to 0.

.inner {
  position: absolute;
  inset: 0;
  background: aqua;
}

Of course, this also applies to a fixed positioned element that you want to fill the viewport with.

.inner {
  position: fixed;
  inset: 0;
  background: aqua;
}

My blog doesn't support comments yet, but you can reply via blog@matuzo.at.