DEV Community

Evan Winter
Evan Winter

Posted on • Edited on

2 1

TIL – CSS inset property shorthand

I recently learned about inset, a CSS shorthand for top, right, left, and bottom properties.

I've used it a lot as a more expressive way of saying, "this thing is full-screen".

For example, to make an element take over the entire screen:

.fullscreen {
  position: fixed;
  inset: 0;
}
Enter fullscreen mode Exit fullscreen mode

It's effectively the same thing as:

.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

// or, what I always used to do...

.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
}
Enter fullscreen mode Exit fullscreen mode

MDN Docs: https://developer.mozilla.org/en-US/docs/Web/CSS/inset

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay