- 樣式一
- 例圖
- 代碼
<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>
- 例圖