Bootstrap的表单

bootstrap 胡碧玉
文章标签: bootstrap 表单

    Bootstrap的表单有三种模式:垂直表单、内联表单、水平表单,其中水平表单使用较多。

    垂直表单的基本代码如下:

    <!--垂直表单:所有表单内容都在垂直方向上(少用)-->
    <form>
    <!--第1步:所有的标签和控件放在一个div中 且class="form-group"-->
      <div class="form-group">
        <label for="name">姓名</label>
        <!--第2步:所有的input/textarea/select控件都添加类名class="form-control"-->
        <input type="text" id="name" class="form-control"/>
      </div>
      <div class="form-group">
        <label for="age">年龄</label>
        <input type="text" id="age" class="form-control"/>
      </div>
    </form>

    内联表单的基本代码如下:

    <!--内联表单:所有表单内容都在水平方向上(少用)-->
    <form class="form-inline"><!--第3步:为表单标签添加类名class=form-inline-->
    <!--第1步:所有的标签和控件放在一个div中 且class="form-group"-->
      <div class="form-group">
        <label for="name">姓名</label>
        <!--第2步:所有的input/textarea/select控件都添加类名class="form-control"-->
        <input type="text" id="name" class="form-control"/>
      </div>
      <div class="form-group">
        <label for="age">年龄</label>
        <input type="text" id="age" class="form-control"/>
      </div>
    </form>

     水平表单的基本代码如下:

<form class="form-horizontal center-block" style="width: 500px;"><!--第2步:form标签添加类名class="form-horizontal"-->
  <!--第1步:所有的标签和控件放在一个div中 且class="form-group"-->
  <div class="form-group">
      <!--第5步:使用栅格系统-->
      <!--第4步:所有的标签都添加类名class="control-label"-->
      <label for="name" class="control-label col-md-2">姓名</label>
      <!--第3步:所有的input/textarea/select控件都添加类名class="form-control"-->
      <div class="col-md-10">
        <input type="text" id="name"  class="form-control"/>
      </div>					
  </div>
  <div class="form-group">
      <label for="age" class="control-label col-md-2">年龄</label>
      <div class="col-md-10">
        <input type="text" id="age"  class="form-control"/>
      </div>
</div>
</form>

还能输出{{restrictNumber}}个字符  
  • {{reply.author}}

    {{CommonUtil.formateDate(reply.ac_CommentDate).shortTime}}
  • 回复了{{Comments.author}} :