Treehouse: Grow your CSS skills. Land your dream job.

floats and widths and border boxes and stuff

  • # November 8, 2012 at 7:20 pm

    When I add margins to the “left” and “right” divs, they no longer float together on the same line. I thought that by making them “border-box”, the size would no longer be affected by margins. Can someone tell me what’s wrong here? Sorry, I’m a bit brain dead after going to the dentist and taking my pain meds, so I don’t feel like thinking too much. Here’s the code and thanks!

    [CodePen Example]( “CodePen Example”)

    # November 8, 2012 at 7:32 pm

    Border-box does not include margins.

    > CSS3 Box-sizing
    > *Method of specifying whether or not an element’s borders and padding should be included in size units*

    # November 8, 2012 at 7:50 pm

    Ah yes, that makes sense. I guess it’s better to use %’s for margin, so I can easily subtract them from the width %, rather than trying to figure out how 10px subtracts from 60%… Thanks!

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

You must be logged in to reply to this topic.