3 min read
•Question 47 of 49easyWhat is the inset Property?
Understanding the inset shorthand for positioning.
What You'll Learn
- inset shorthand
- Replaces top/right/bottom/left
- Usage patterns
Syntax
styles.cssCSS
.element {
/* All sides */
inset: 0;
/* Vertical | Horizontal */
inset: 10px 20px;
/* Top | Horizontal | Bottom */
inset: 10px 20px 30px;
/* Top | Right | Bottom | Left */
inset: 10px 20px 30px 40px;
}Replaces
styles.cssCSS
/* Old way */
.element {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
/* New way */
.element {
position: absolute;
inset: 0;
}Common Patterns
styles.cssCSS
/* Full coverage overlay */
.overlay {
position: fixed;
inset: 0;
}
/* Partial coverage */
.sidebar {
position: fixed;
inset: 0 auto 0 0;
width: 300px;
}