Bootstrap实现注册界面

  • 样式一
    • 例图

       

    • 代码
      <head>
          <meta charset="UTF-8">
          <title>用户注册</title>
          <link href="bootstrap-4.3.1-dist/css/bootstrap.min.css" rel="stylesheet">
          <script src="https://code.jquery.com/jquery.js"></script>
          <script src="bootstrap-4.3.1-dist/js/bootstrap.js"></script>
          <style>
      
              .container {
                  margin-top: 15%;
                  width: 35%;
              }
      
              .btn-primary {
                  background-color: #337ab7;
                  border-color: #337ab7;
              }
      
              .form-control {
                  margin-bottom: 4px;
              }
      
          </style>
      </head>
      <body>
      <div class="container">
          <form>
              <div class="form-signin">
                  <!--<h2 class="form-signin-heading">注册</h2>-->
                  <!-- class="sr-only"将label标签隐藏 -->
                  <label for="exampleInputUsername" class="sr-only">用户名</label>
                  <input type="text" class="form-control" id="exampleInputUsername" placeholder="用户名">
                  <label for="exampleInputUsername" class="sr-only">密码</label>
                  <input type="password" class="form-control" id="exampleInputPassword" placeholder="密码">
                  <label for="exampleInputUsername" class="sr-only">邮箱</label>
                  <input type="email" class="form-control" id="exampleInputEmail" placeholder="邮箱">
                  <label for="exampleInputUsername" class="sr-only">手机</label>
                  <input type="tel" class="form-control" id="exampleInputPhone" placeholder="手机">
                  <div class="checkbox">
                      <label>
                          <!--<input type="checkbox">
                          记住密码-->
                      </label>
                  </div>
                  <button class="btn btn-lg btn-primary btn-block" type="submit">注册</button>
              </div>
          </form>
      </div>
      
      </body>
      </html>

       

  • 样式二
    • 例图

       

    • 代码
      <head>
          <meta charset="UTF-8">
          <title>用户注册</title>
          <link href="bootstrap-4.3.1-dist/css/bootstrap.min.css" rel="stylesheet">
          <script src="https://code.jquery.com/jquery.js"></script>
          <script src="bootstrap-4.3.1-dist/js/bootstrap.js"></script>
          <style>
      
             .container1 {
                  margin-top: 70px;
                  width: 45%;
                  margin-left: 30%;
              }
      
              /* 需要在一行的元素 */
              .inline-style {
                  display: inline-block;
              }
              /* 文字需要靠右 */
              .font-position-right{
                  text-align: right;
              }
              /* 注册按钮 */
              .register-btn{
                  margin-left: 10%;
              }
      
      
          </style>
      </head>
      <body>
      <div class="container1">
      
          <form class="form-horizontal">
              <div class="form-group">
                  <!--<h2 class="form-signin-heading">注册</h2>-->
                  <!-- class="sr-only"将label标签隐藏 -->
                  <label for="exampleInputUsername1" class="col-sm-2 control-label inline-style font-position-right">用户名</label>
                  <div class="col-sm-9 inline-style ">
                      <input type="text" class="form-control" id="exampleInputUsername1" placeholder="用户名">
                  </div>
              </div>
              <div class="form-group">
                  <!--<h2 class="form-signin-heading">注册</h2>-->
                  <label for="exampleInputUsername1" class="col-sm-2 control-label  inline-style font-position-right">密码</label>
                  <div class="col-sm-9  inline-style">
                      <input type="password" class="form-control" id="exampleInputPassword1" placeholder="密码">
                  </div>
              </div>
              <div class="form-group">
                  <label for="exampleInputUsername1" class="col-sm-2 control-label  inline-style font-position-right">邮箱</label>
                  <div class="col-sm-9  inline-style">
                      <input type="email" class="form-control" id="exampleInputEmail1" placeholder="邮箱">
                  </div>
                  <div class="form-group">
                  </div>
              </div>
              <div class="form-group">
                  <label for="exampleInputUsername1" class="col-sm-2 control-label   inline-style font-position-right">手机</label>
                  <div class="col-sm-9  inline-style">
                      <input type="tel" class="form-control" id="exampleInputPhone1" placeholder="手机">
                  </div>
              </div>
              <div class="form-group">
                  <div class="col-sm-offset-2 col-sm-10">
                      <div class="checkbox">
                          <label>
                              <!--<input type="checkbox">
                              记住密码-->
                          </label>
                      </div>
                  </div>
              </div>
      
              <div class="form-group">
                  <div class="col-sm-offset-2 col-sm-10">
                      <button class="btn btn-lg btn-primary btn-block register-btn" type="submit">注册</button>
                  </div>
      
              </div>
          </form>
      
      </div>
      
      </body>
      </html>

       

  •   

 

posted @ 2019-04-23 11:43  好胖的兔子  阅读(8998)  评论(0编辑  收藏  举报