user979331
user979331

Reputation: 11841

CSS background color height 100% not working

I have a div like so:

<div class="background"></div>

and I am trying to give it 100% height so the background color is the whole div. Here is my CSS:

html, body {
  height: 100%;
}

.background {
  background-color: #1D3862;
  clear: both;
  height: 100%;
}

but its not working...what can I do to fix this ?

Upvotes: 0

Views: 2643

Answers (1)

Paulie_D
Paulie_D

Reputation: 114991

You need to remove the default margin from the body

html, body {
  height: 100%;
    margin: 0;
}

html,
body {
  height: 100%;
  margin: 0;
}
.background {
  background-color: #1D3862;
  height: 100%;
}
<div class="background"></div>

Upvotes: 2

Related Questions