Andy
Andy

Reputation: 3682

Make DIV overide margins of parent

I'm not sure how best to explain this, but I'll do my best. I have Drupal theme that has a shadow border and text padding on the main content/post DIV. However, on some pages, I would like to override the text padding so that a DIV tag can be full with of the content DIV.

I could probably achieve the same sort of thing by removing the text padding and adding it manually on each page, but this would be a lot of work; especially considering that I would only need to use this "special" DIV on a few pages.

I hope that makes some sense - there's probably a better way to explain it though which is why I can not find the answer myself! Thanks in advance

Upvotes: 0

Views: 67

Answers (1)

Matt Whipple
Matt Whipple

Reputation: 7134

Use a negative margin on the child that is equal to the parent's padding. I.e:

div.parent {
  padding: 0 10px;
}

div.child {
  margin: 0 -10px;
}

Upvotes: 2

Related Questions