Tom
Tom

Reputation: 9643

div inside a div Css background color problem

I want the outer div to span to all the page width with the background color #efefef. The inner div will be centered and have white background with 995px width.

So i have this code:

  <div style="background-color:#efefef;width:100%;">
    <div id="photoUploadWrap">

Now the photoUploadWrap style is:

#photoUploadWrap{width: 995px;margin: auto;}

And it has tables and more divs inside it. The div gets centered alright but the outer div doesn't display the #efefef background.

What's wrong here? I also tried to put a border on the outer div with no success.

Upvotes: 1

Views: 16194

Answers (2)

Lauw
Lauw

Reputation: 1715

Not sure why this isnt working, but when I changed it to:

  <div id="divContainer">
    <div id="photoUploadWrap">
aaaa
      </div>
</div>

#photoUploadWrap{width: 995px;margin: 0 auto;}
#divContainer { width: 100%; background-color: #efefef; }

it worked. check it Live

Upvotes: 0

Brandon Montgomery
Brandon Montgomery

Reputation: 6986

The outer div has no height (or at least the browser doesn't think so). This is why you don't see the border or the background color. Why not just set the background color on the body tag?

Upvotes: 2

Related Questions