与表单一起使用时,Bootstrap 4布局无法正常工作

时间:2017-04-14 12:01:37

标签: html twitter-bootstrap css3 bootstrap-4

我在表单上使用Bootstrap 4。现在,当将表单与网格类一起使用时,它实际上并不像它应该的那样工作。可以在此处看到输出http://www.henryspike.tk/testform

我所期待的是看到整个12列分为4-4-4,每列包含一个输入字段,但它堆积起来。

<div class="row">
                    <div class="col-md-12 offset-md-1">
                        <div class="row">
                            <form class="form">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="name">Name</label>
                                        <input class="form-control" type="text" name="name" id="name" placeholder="eg. John Doe" required>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="email">Name</label>
                                        <input class="form-control" type="email" name="email" id="email" placeholder="someone@example.com" required>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="username">Name</label>
                                        <input class="form-control" type="text" name="username" id="username" placeholder="eg. JDoe12" required>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>

1 个答案:

答案 0 :(得分:3)

col-应该始终是row直接子项。

http://www.codeply.com/go/moFmNMMuPs

<div class="row">
    <div class="col-md-12">
        <form class="row form">
            <div class="col-md-4">
                <div class="form-group">
                    <label for="name">Name</label>
                    <input class="form-control" type="text" name="name" id="name" placeholder="eg. John Doe" required="">
                </div>
            </div>
            <div class="col-md-4">
                <div class="form-group">
                    <label for="email">Name</label>
                    <input class="form-control" type="email" name="email" id="email" placeholder="someone@example.com" required="">
                </div>
            </div>
            <div class="col-md-4">
                <div class="form-group">
                    <label for="username">Name</label>
                    <input class="form-control" type="text" name="username" id="username" placeholder="eg. JDoe12" required="">
                </div>
            </div>
        </form>
    </div>
</div>