<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <!-- 支持移动设备优先 --> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <!-- 导入CSS文件 --> <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"> <!-- 引入js --> <!-- bootstrap.js 引入必须依赖 jQuery, jQuery需要自行去下载导入进来 --> <script src="bootstrap/js/jquery-3.4.1.js"></script> <!-- 不引入 jQuery 则会报错 Uncaught Error: Bootstrap's JavaScript requires jQuery --> <script src="bootstrap/js/bootstrap.js"></script> </head> <body> <div class="container"> <form action="" class="form-horizontal"> <!-- 栅格系统 是由行与列组成的,class="form-group" 就表示行 row--> <div class="form-group"> <label for="user" class="col-md-2 control-label">用户名</label> <input class="col-md-4" type="text" class="form-control" id="user" placeholder="用户名"> </div> <div class="form-group"> <label for="pass" class="col-md-2 control-label">密码</label> <input class="col-md-4" type="text" class="form-control" id="pass" placeholder="密码"> </div> <div class="form-group"> <div class="col-md-4 col-md-offset-2"> <div class="checkbox"> <label> <input type="checkbox"> 记住我 </label> </div> </div> </div> <div class="form-group"> <div class="col-md-4 col-md-offset-2"> <div class="radio"> <label> <input type="radio"> 记住我 </label> </div> </div> </div> <div class="form-group"> <div class="col-md-4 col-md-offset-2"> <button type="submit" class="btn btn-success">提交</button> </div> </div> </form> </div> </body> </html>
- demo 效果: