How to use border with Bootstrap

后端 未结 9 722
独厮守ぢ
独厮守ぢ 2020-12-23 15:53

How can I solve this problem? When you add borders to a div, the div is not centered and the span12 class is not centered.

I would like to center the di

相关标签:
9条回答
  • 2020-12-23 16:43

    Unfortunately, that's what borders do, they're counted as part of the space an element takes up. Allow me to introduce border's less commonly known cousin: outline. It is virtually identical to border. Only difference is that it behaves more like box-shadow in that it doesn't take up space in your layout and it has to be on all 4 sides of the element.

    http://codepen.io/cimmanon/pen/wyktr

    .foo {
        outline: 1px solid orange;
    }
    
    0 讨论(0)
  • 2020-12-23 16:43

    As of Bootstrap 3, you can use Panel classes:

    <div class="panel panel-default">Surrounded by border</div>

    In Bootstrap 4, you can use Border classes:

    <div class="border border-secondary">Surrounded by border</div>

    0 讨论(0)
  • 2020-12-23 16:46

    If you are using Bootstrap 4 and higher try this to put borders around your empty divs use border border-primary here is an example of my code:

    <div class="row border border-primary">
            <div class="col border border-primary">logo</div>
            <div class="col border border-primary">navbar</div>
        </div>
    

    Here is the link to the border utility in Bootstrap 4: https://getbootstrap.com/docs/4.2/utilities/borders/

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