Bootstrap 3: Missing gutters

后端 未结 2 494
耶瑟儿~
耶瑟儿~ 2020-12-08 09:42

Just started playing around with bootstrap 3 and I can\'t get gutters between columns to work.

I created the most basic code to test with:



        
相关标签:
2条回答
  • 2020-12-08 10:32

    Bootstrap 3 switched to using padding for the gutters rather than margins. So, the content is parted, but the boxes aren't. And a background-color will fill the padding as well.

    Though, you should be able to get the desired effect by setting the background on inner boxes:

    <div class="row">
        <div class="col-sm-4">
            <div class="box1">
                <h1>Test</h1>
            </div>
        </div>
        <div class="col-sm-8">
            <div class="box2">
                <h1>Test2</h1>
            </div>
        </div>
    </div>
    

    http://jsfiddle.net/PFxUk/


    Though, the goal is just to apply the background to a single, wrapping child. So, if the headers definitely won't have any siblings, then you can possibly forgo the additional <div>s:

    <div class="row">
        <div class="col-sm-4">
            <h1 class="box1">Test</h1>
        </div>
        <div class="col-sm-8">
            <h1 class="box2">Test2</h1>
        </div>
    </div>
    

    http://jsfiddle.net/G2gbG/

    0 讨论(0)
  • 2020-12-08 10:45

    If you want to set the padding or margin for your columns, you can use the row-no-gutters class on the row (introduced in v3.4.0) and add your own padding and background.

    https://getbootstrap.com/docs/3.4/css/#grid-remove-gutters

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