Why are borders causing div to overflow container?

前端 未结 1 896
伪装坚强ぢ
伪装坚强ぢ 2021-01-25 10:38

I have a section set to a fixed width and a 100% width div inside of it with a 5 pixel border.

Looks fine but you can tell the containing div is a bit off center and it

相关标签:
1条回答
  • 2021-01-25 10:50

    Add box-sizing: border-box; to your info-box class

    .info-box {
        background: rgba(248, 243, 232, 0.5) none repeat scroll 0 0;
        border: 5px solid #0033a0;
        box-sizing: border-box;
        display: inline-block;
        padding: 48px 0;
        text-align: center;
        width: 100%;
    }
    

    box-sizing is better explained here https://css-tricks.com/box-sizing/

    0 讨论(0)
提交回复
热议问题