Forums

  • # April 26, 2013 at 3:43 am

    I was using “inner” as a child div with a padding of 20px.
    The issue is, when I float an element to the left and the second element to the right the “inner” div totally collapses.
    Acts as if there is no padding at all…
    I’d have to add a second class attribute named “clearfix” just so the parent div can expand to fit all of it’s content…
    I find it quite annoying to repeatedly add “clearfix” to every single div that needs the padding…
    I also use 2 divs named “left” and “right” that obviously float left and right.
    What can I do to fix this?

    Please, Help.

    [Fiddle](http://jsfiddle.net/WV3qv/2/ “http://jsfiddle.net/WV3qv/2/”)

    # April 26, 2013 at 5:26 am

    @atelierbram What exactly is flexbox?

    # April 26, 2013 at 5:33 am

    > What can I do to fix this?

    You could also look into `inline-block`.

    http://joshnh.com/2012/02/07/why-you-should-use-inline-block-when-positioning-elements/

    # April 26, 2013 at 5:38 am

    >I was using “inner” as a child div with a padding of 20px.

    On thinking about it….Why? Can’t you add the padding to the header?

    http://jsfiddle.net/yehbd/1/

    # April 26, 2013 at 7:28 am

    I like Paulie’s idea, or you could simply add overflow: hidden; to the padded child and not need to add a class every time.

    # April 26, 2013 at 12:44 pm

    @paulie_d I wanted the padding inside of specific divs without expanding the parent….

    # April 26, 2013 at 2:08 pm

    Then you can use

    `box-sizing:border-box`

    That will solve it. – http://codepen.io/anon/pen/dpjyq

    # April 26, 2013 at 7:15 pm

    @paulie_d does that work on all browsers?
    I will give it a try :)
    Thank you.

    # April 26, 2013 at 8:34 pm

    http://caniuse.com/#feat=css3-boxsizing

    Pretty much all browsers yeah ^^

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag