3

我用 Bootstrap 4 开发了一个静态 HTML 页面,使用col与大屏幕相等但在Extra small屏幕上,col 没有得到100% width. 我忘记了什么?

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" />
<div class="container">
     <div class="form-row">
        <!-- Grid column -->
        <div class="col col-6">
            <!-- Material input -->
            <div class="md-form">
                <input type="text" class="form-control" placeholder="City">
            </div>
        </div>
        <!-- Grid column -->

        <!-- Grid column -->
        <div class="col">
            <!-- Material input -->
            <div class="md-form">
                <input type="text" class="form-control" placeholder="State">
            </div>
        </div>
        <!-- Grid column -->

        <!-- Grid column -->
        <div class="col">
            <!-- Material input -->
            <div class="md-form">
                <input type="text" class="form-control" placeholder="Zip">
            </div>
        </div>
        <!-- Grid column -->
    </div>
    </div>

4

1 回答 1

2

超小 col 宽度 100% 不工作

列不是 100% 宽度,因为col是最小屏幕尺寸的自动布局列xs,因此列将继续缩小宽度,并且永远不会垂直堆叠。

改用col-sm...

https://www.codeply.com/go/xb7WffaSmS

<div class="container">
    <div class="form-row">
        <!-- Grid column -->
        <div class="col-sm-6">
            <!-- Material input -->
            <div class="md-form">
                <input type="text" class="form-control" placeholder="City">
            </div>
        </div>
        <!-- Grid column -->

        <!-- Grid column -->
        <div class="col-sm">
            <!-- Material input -->
            <div class="md-form">
                <input type="text" class="form-control" placeholder="State">
            </div>
        </div>
        <!-- Grid column -->

        <!-- Grid column -->
        <div class="col-sm">
            <!-- Material input -->
            <div class="md-form">
                <input type="text" class="form-control" placeholder="Zip">
            </div>
        </div>
        <!-- Grid column -->
    </div>
</div>

另请注意,中-xs缀已在 Bootstrap 4 中删除。现在最小的类是 simple colcol-6col-12等......

于 2018-04-12T11:57:46.700 回答