twitter-bootstrap 引导表单组 vs 行 CSS 哪个更喜欢

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28090256/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 22:12:27  来源:igfitidea点击:

bootstrap form-group vs row CSS which one prefer

csstwitter-bootstrap

提问by Viraj

I have used rowand now using form-groupCSS. I am confused between these 2, which one should I prefer if I want to build form controls. Seems like both do same job.

我使用过,现在使用表单组CSS。我在这两个之间感到困惑,如果我想构建表单控件,我应该更喜欢哪一个。似乎两者都做同样的工作。

采纳答案by hamed

I usually follow this pattern:

我通常遵循这种模式:

<div class="form-group">
   <div class="row">
        <div class="col-md-6"></div>
        <div class="col-md-6"></div>
   </div>
</div>

Note the col-md-6and col-md-5are examples and you can use any col-md-xclass with unlimited number. just sum MUST be 12.

注意col-md-6col-md-5是示例,您可以使用任何col-md-x数量不限的类。总和必须是 12。

回答by JTech

The direct answer to your question is in the documentation:

您的问题的直接答案在文档中:

".form-row" is a variation of our standard grid class ".row" which overrides the default column gutters for tighter and more compact layouts

“.form-row”是我们标准网格类“.row”的变体,它覆盖了默认的列间距以获得更紧凑和更紧凑的布局

See here: https://getbootstrap.com/docs/4.0/components/forms/#form-grid

请参阅此处:https: //getbootstrap.com/docs/4.0/components/forms/#form-grid

回答by Keenan Stewart

This is for Bootstrap.

这是针对 Bootstrap 的。

form-group per set of controls on a form. If your row has multiple cols, and each col has a label and an input text, put a form-group around each label and input control, such as:

表单上的每组控件的表单组。如果您的行有多个列,并且每个列都有一个标签和一个输入文本,请在每个标签和输入控件周围放置一个表单组,例如:

<div class="row">
    <div class="col-6">
        <div class="form-group">
            <label>Client Name: </label>
            <input type="text" name="clientName" />
        </div>
    </div>

    <div class="col-6">
        <div class="form-group">
            <label>Client Email: </label>
            <input type="text" name="clientEmail />
        </div>
    </div>
</div>

... etc.