Bootstrap and 1 px height on col - why?

2020-08-17 18:30发布

问题:

Can someone explain to me why BS has a 1px height set by default? IT was this way in 2 and 3 and I never understood why? I know it says in the comments "Prevent columns from collapsing when empty" but what browsers does it do this?

回答1:

Try and you will know: http://bootply.com/82722

<div class="container" style="background-color:orange;">
    <div class="row">
    <div class="col-sm-6" style="background-color:blue;"></div>
    <div class="col-sm-6" style="background-color:red;">right</div>
    </div>
</div>
<div class="container" style="background-color:orange;">
    <div class="row">
    <div class="col-sm-6" style="background-color:blue;min-height:0"></div>
    <div class="col-sm-6" style="background-color:red;">right</div>
    </div>
</div>


回答2:

// Prevent columns from collapsing when empty
min-height: 1px;

Source: http://getbootstrap.com/css/#grid