Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Padding, what are you doing? Padding! NO! STAHP!

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #41192
    JoniGiuro
    Participant

    Hi,
    I’ve been front ending for a couple of years now and I always find this situation where I want an element to be an exact number of pixels and have some exact padding.
    Some time ago I used to set the width of the element MINUS the padding * 2 and that worked. Then I got tired of calculating and started adding an inner div, so I could set the width of the parent easily and set the padding to the inner element, but this also looks like a crappy solution, so I was wondering how you guys handle these situations.
    I know about box-sizing: border-box but I don’t want to use it due to browser inconsistencies.

    Here’s a fiddle to show the problem and my usual solution (case 2)

    http://codepen.io/joe/pen/boABp

    Thanks and bye :)

    #116483
    Kitty Giraudel
    Participant

    My way to go is the following:
    * Box-sizing: border-box on all elements *, *:after, *:before { box-sizing: border-box; }
    * Polyfill for IE7 if support required (https://github.com/Schepp/box-sizing-polyfill)

    I do that in most projects, it works absolutely fine.

    #116490
    JoniGiuro
    Participant

    ok, I’ll give it a try, thanks

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.