Jay Flood
Jay Flood

Reputation: 3

how to set a div to 100% width within a parent div that has 40px padding

I may have asked this question in a confusing way.

Basically I need this: http://www.jayflood.com/layout.jpg

I'm sure there are a ton of ways to do this, but my problem lies in working within a preexisting structure. The parent container does not have a set width, but does have 40px of padding.

I need the content div to be considered width 100% so I can properly divide up the divs within.

The question is basically - Is it possible to have a smaller containing div have a 100% width.

Upvotes: 0

Views: 99

Answers (2)

Eric
Eric

Reputation: 368

subtract the padding using a negative margin so if the parent has 40px padding then set the child to have -40px margin ex.

#parent{
  padding: 40px;
}

and

#child{
  width: 100%;
  margin: -40px;
}

Upvotes: 0

Oussama Gammoudi
Oussama Gammoudi

Reputation: 761

set its margin to -40px

div {
   margin:-40px;
}

Upvotes: 1

Related Questions