DEV Community

Discussion on: CSS gotcha: How to fill page with a div?

Collapse
 
dd profile image
D

What about this?

div {
  position: absolute;
  top: 0;
  left: 0; 
  right: 0;
  bottom: 0;
  background: #fb1;
}
Enter fullscreen mode Exit fullscreen mode

It's enough to fill entire page without effort.

Collapse
 
lennythedev profile image
Lenmor Ld

Thanks for the note. Yes, this is definitely another way to do this. For this post though, I wanted to explore more of an alternative "relative" solution without using absolute positioning and dealing with z-index.