Posted By

Uzbekjon on 07/07/08


Tagged

css hack ie boxmodel


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

heinz1959
SpinZ
basicmagic
scitrenbaumgmailcom


Overcoming the Box Model Hack


 / Published in: CSS
 

If you want to specify a width to any div, do NOT specify padding or margins. Just create an inner div with no width set and specify its padding and margins instead.

  1. /*
  2.   Instead of this
  3. */
  4. #main-div{
  5. width: 150px;
  6. border: 5px;
  7. padding: 20px;
  8. }
  9.  
  10. /*
  11.   Do this
  12. */
  13. #main-div{
  14. width: 150px;
  15. }
  16. #main-div div{
  17. border: 5px;
  18. padding: 20px;
  19. }

Report this snippet  

You need to login to post a comment.