Twitter Bootstrap - borders

前端 未结 2 519
盖世英雄少女心
盖世英雄少女心 2020-12-07 09:51

I just started using Twitter Bootstrap, and I have a question about how to best add a border to a parent element?

for instance, if I have

 
2条回答
  •  庸人自扰
    2020-12-07 10:32

    Another solution I ran across tonight, which worked for my needs, was to add box-sizing attributes:

    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    

    These attributes force the border to be part of the box model's width and height and correct the issue as well.

    According to caniuse.com » box-sizing, box-sizing is supported in IE8+.

    If you're using LESS or Sass there is a Bootstrap mixin for this.

    LESS:

    .box-sizing(border-box);
    

    Sass:

    @include box-sizing(border-box);
    

提交回复
热议问题