Bootstrap基本样式学习笔记之表单(3)
Bootstrap 通过一些简单的 HTML 标签和扩展的类即可创建出不同样式的表单。
0x01 样式1
一个登录界面:
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="../../css/bootstrap.min.css" rel="stylesheet"> <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <script src="../../js/bootstrap.min.js"></script> <title>用户登录</title> </head> <body> <div class="container"> <form> <div class="form-group"> <label for="UserName">用户名</label> <input type="text" class="form-control" id="UserName" placeholder="用户名"> </div> <div class="form-group"> <label for="PassWord">密 码</label> <input type="password" class="form-control" id="PassWord" placeholder="密码"> </div> <div class="form-group"> <label> <input type="checkbox">记住我吗? </label> </div> <div class="form-group"> <input type="button" class="btn btn-default" id="Submit" value="登 录"> </div> </form> </div> </body> </html>
效果如下:
0x02 样式2
如果要将label与文本框在同一行显示,修改如下:
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="../../css/bootstrap.min.css" rel="stylesheet"> <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <script src="../../js/bootstrap.min.js"></script> <title>用户登录</title> </head> <body> <div class="container"> <div class="col-lg-3 col-md-3 col-xs-3"></div> <div class="col-lg-6 col-md-6 col-xs-6"> <div class="page-header"> <h1>用户登录</h1> </div> <form class="form-horizontal"> <div class="form-group"> <div class="col-lg-2 col-sm-2 col-xs-2"> <label for="UserName" class="control-label">用户名:</label> </div> <div class="col-lg-10 col-sm-10 col-xs-10"> <input type="text" class="form-control" id="UserName" placeholder="用户名"> </div> </div> <div class="form-group"> <div class="col-lg-2 col-sm-2 col-xs-2"> <label for="PassWord" class="control-label">密 码:</label> </div> <div class="col-lg-10 col-sm-10 col-xs-10"> <input type="password" class="form-control" id="PassWord" placeholder="密码"> </div> </div> <div class="form-group"> <div class="col-lg-2 col-sm-2 col-xs-2"></div> <div class="col-lg-10 col-sm-10 col-xs-10"> <div class="checkbox"> <label> <input type="checkbox">记住我吗? </label> </div> </div> </div> <div class="form-group"> <div class="col-lg-2 col-sm-2 col-xs-2"></div> <div class="col-lg-10 col-sm-10 col-xs-10"> <input type="button" class="btn btn-default" id="Submit" value="登 录"> </div> </div> </form> </div> <div class="col-lg-3 col-md-3 col-xs-3"></div> </div> </body> </html>
效果如下:
0x03 样式3
如果将文本框放在同一行,修改如下:
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="../../css/bootstrap.min.css" rel="stylesheet"> <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <script src="../../js/bootstrap.min.js"></script> <title>用户登录</title> </head> <body> <div class="container"> <form class="form-inline"> <div class="form-group"> <label class="control-label" for="UserName">用户名:</label> <input type="text" class="form-control" id="UserName" placeholder="用户名"> </div> <div class="form-group"> <label class="control-label" for="PassWord">密 码:</label> <input type="password" class="form-control" id="PassWord" placeholder="密码"> </div> <div class="form-group"> <div class="checkbox"> <label> <input type="checkbox">记住我吗? </label> </div> </div> <div class="form-group"> <input type="button" class="btn btn-default" id="Submit" value="登 录"> </div> </form> </div> </body> </html>
效果如下:
相关推荐
niepxiya 2019-09-05
TemplarAssassin 2017-10-25
TemplarAssassin 2017-10-16
jingtianyiyi 2015-12-16
happyzhangyin 2013-11-11
jingtianyiyi 2017-03-10
移动开发与培训 2017-05-23
soulis 2017-05-23
hllinc 2017-05-23
乔乔 2017-05-18
iChangebaobao 2017-05-17
soulis 2017-05-17
qiukui00 2017-03-29
zh000 2017-03-29
CoderEight 2017-03-17
lixia 2017-03-10
ReunionIsland 2017-03-10