DEV Community

Nganggur Dev
Nganggur Dev

Posted on • Edited on • Originally published at nganggurdev.com

Learn CSS for Beginners #8: CSS Positioning All Explained - Fixed, Relative, Static, and Absolute

CSS positioning – fixed, relative, absolute, static

Struggling with weird layouts or elements overlapping where they shouldn’t? You’re probably bumping into one of the trickiest parts of CSS for beginners: positioning.

In this guide, I break down the 4 main position values in CSS:

static– the default, normal flow
relative– shift an element slightly without affecting others
absolute– position exactly where you want inside a parent
fixed– stick to the screen even when scrolling

Why CSS Positioning Confuses Many Beginners
The position property changes how an element behaves in the document flow. It affects stacking, layout, and responsiveness.

Once you understand how positioning works, you’ll unlock the ability to create:

  • Sticky navbars
  • Custom tooltips
  • Floating buttons
  • Fixed Banners

Quick Example:

.box {
  position: absolute;
  top: 50px;
  left: 100px;
}
Enter fullscreen mode Exit fullscreen mode

This code places .box exactly 50px from the top and 100px from the left of its positioned ancestor.

👉 In the full guide, I explain when and why to use each type — with code snippets and real layout examples:
How Margin, Padding, and Border Work in CSS with Examples

Top comments (0)