CSS positioning lets you position elements anywhere on the screen, overlay modal dialogs, and create sticky navigation headers.
1. The 5 Position Values
⊞Code Example
/* Sticky Navigation Bar */
.header-nav {
position: sticky;
top: 0;
z-index: 50;
background-color: #060c18;
border-bottom: 1px solid #1e293b;
}
/* Card with Floating Absolute Badge */
.card-container {
position: relative; /* Anchor parent */
background-color: #0c1328;
padding: 24px;
border-radius: 16px;
}
.hot-badge {
position: absolute;
top: -10px;
right: -10px;
background-color: #f43f5e;
color: #ffffff;
padding: 4px 10px;
font-size: 11px;
font-weight: 800;
border-radius: 9999px;
}
