Skip to main content
LGMTL
Inspiring
May 25, 2017
Answered

Border-box within Fluid-grid layout extends beyond border

  • May 25, 2017
  • 1 reply
  • 534 views

Hello,

I noticed that when I applied a box-sizing: border-box attribute to a Fluid-grid div and added some padding that the div extends outside the boundaries, is this normal?

http://prntscr.com/fbt1v5

Is border-box not meant to prevent this very thing?

Brandon

    This topic has been closed for replies.
    Correct answer Jon Fritz

    Oh I thought all the divs were supposed to line up with border-box attribute... not sure why they stick out like that. I will remove the padding and add a div with padding within that div to see if that's the issue.


    Border-box only makes it so the border and padding are included in the element's width and height settings.

    For example, if you have an element set to a 500 pixel width, then add padding of 20 pixels and a border of 10 pixels all the way around, the element will be 560 pixels wide (10 + 20 + 500 + 20 + 10).

    With box-sizing set to border-box, the padding and border move inside the element's width setting so the full width stays as 500 pixels even with 60 pixels of padding and border added.

    When percentages are used, the same thing happens. Without box-sizing set to border box, in the example above a 100% width turns into 100% + 60 px.

    1 reply

    BenPleysier
    Community Expert
    Community Expert
    May 25, 2017

    Yes, border-box should prevent this.

    The only thing I can think of is that the containing div is the one that extends beyond the parameters. Please show your markup and style rules so that we can determine where the problem lies.

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
    LGMTL
    LGMTLAuthor
    Inspiring
    May 25, 2017

    Hi Ben,

    Here's the markup: Private Paste ID: kbaVJe6M

    Here're the CSS rules: Private Paste ID: jGRz98EJ

    I've simplified it down to only mobile.

    Thanks for your help!

    Brandon

    BenPleysier
    Community Expert
    Community Expert
    May 25, 2017

    Sorry, I do not have permission to view the code.

    The best way is to paste the code here.

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!