Home  >  Article  >  Web Front-end  >  Bootstrap basic tutorial form part example code

Bootstrap basic tutorial form part example code

青灯夜游
青灯夜游forward
2018-10-13 16:10:593295browse

This article will bring you the example code of the form part of the Bootstarp basic tutorial. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. You can also visit bootstrap tutorial to get and learn more bootstrap related video tutorials.

bootstrap form part, the specific code is as follows:

<p class="container">
  <form action="#" method="post">
    <fieldset>
      <legend>用户登陆</legend>
      <p class="form-group">
        <label>用户名:</label>
        <input type="text" class="form-control" name="name" placeholder="用户名">
      </p>
      <p class="form-group">
        <label>密码:</label>
        <input type="password" class="form-control" name="pwd" placeholder="密码">
        <!--form-control代表的是占满容器-->
      </p>
      <p class="checkbox">
        <label><input type="checkbox">记住密码</label>
      </p>
      <!--多选框必须这么写 不然会造成选框与文本重叠的问题-->
      <p class="form-group">
        <button type="submit" class="btn btn-default">提交</button>
      </p>
    </fieldset>
  </form>
</p>

inline form and label hidden

<p class="container">
  <form action="#" method="post" class="form-inline">
    <!--form-inline让表单横向放置-->
    <fieldset>
      <legend>用户登陆</legend>
      <p class="form-group">
        <label class="sr-only">用户名:</label>
        <!--sr-only让label隐藏-->
        <input type="text" class="form-control" name="name" placeholder="用户名">
      </p>
      <p class="form-group">
        <label>密码:</label>
        <input type="password" class="form-control" name="pwd" placeholder="密码">
        <!--form-control代表的是占满容器-->
      </p>
      <p class="checkbox">
        <label><input type="checkbox">记住密码</label>
      </p>
      <!--多选框必须这么写 不然会造成选框与文本重叠的问题-->
      <p class="form-group">
        <button type="submit" class="btn btn-default">提交</button>
      </p>
    </fieldset>
  </form>
</p>

Put label and input in Methods in the same line

<p class="container">
  <form action="#" method="post" class="form-horizontal">
    <!--form-horizontal让表单初始化-->
    <fieldset>
      <legend>用户登陆</legend>
      <p class="form-group">
        <label class="col-xs-3 control-label">用户名:</label>
        <!--借助栅格系统设置label的宽度-->
        <p class="col-xs-9">
          <input type="text" class="form-control" name="name" placeholder="用户名">
        </p>
        <!--用p设置栅格并包裹input-->
      </p>
  </form>
</p>
<!--注意!把label和input放在同一行在768分辨率一下是有问题的 在md和lg上正常-->

Adding small icons

<p class="container">
  <form action="#" method="post" class="form-horizontal">
    <!--form-horizontal让表单初始化-->
    <fieldset>
      <legend>用户登陆</legend>
      <p class="form-group has-feedback has-success">
        <!--在项目的p外包围class加has-feedback-->
        <label class="col-xs-3 control-label">用户名:</label>
        <p class="col-xs-9">
          <input type="text" class="form-control" name="name" placeholder="用户名">
          <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
          <!--在input之下添加一个span 记得加form-c-f-->
        </p>
      </p>
  </form>
</p>

A bunch of button components

<p class="container">
  <p class="btn-toolbar">
    <p class="btn-group">
      <button class="btn btn-success"><span class="glyphicon glyphicon-star"></span></button>
      <button class="btn btn-info"><span class="glyphicon glyphicon-star"></span></button>
      <button class="btn btn-danger"><span class="glyphicon glyphicon-star"></span></button>
      <button class="btn btn-default"><span class="glyphicon glyphicon-star"></span></button>
    </p>
  </p>
</p>

Don’t force it Make a button separation because this is a group of buttons in the middle that are not rounded

Search box

<p class="col-md-4 col-md-offset-2">
  <p class="input-group input-lg">
    <p class="input-group-addon">
      <a href=""><span class="glyphicon glyphicon-star"></span></a>
    </p>
      <input type="text" class="form-control input-xs">
    </p>
  </p>
</p>

Summary: The above is the basics of Bootstarp introduced to you. The entire content of the form part of the tutorial, I hope it will be helpful to everyone's learning.

Related recommendations:

What is Bootstrap? A brief introduction to Bootstrap

What are the ways to layout Bootstrap forms? How to create Bootstrap form layout

Bootstrap Chinese Manual

The above is the detailed content of Bootstrap basic tutorial form part example code. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:织梦者. If there is any infringement, please contact admin@php.cn delete