Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stretching DIV totally across screen

Tags:

html

css

width

So, here's my situation:

I have a div (see the code below), a pretty simple . When running the code, I come up with a gray box. BUT, my intention was for that gray box to span from the start of the browser window to the END of that browser window, while what the code below does is creating a gray box with what seems to be a white border.

<div style="height: 30px; background-color: gray; color: white;">
   Hey
</div>

I'm sorry for the lack of explanation, but I found no good way to word what I was trying to do. Thanks in advance,

Tom.

like image 294
Thomas Gouder Avatar asked Dec 20 '22 03:12

Thomas Gouder


1 Answers

If you want a div to fill all available space use the following:

width: 100%; 
height: 100%;

You can define sizes in percentages of available space.

like image 119
Christian Stewart Avatar answered Dec 22 '22 18:12

Christian Stewart