Bootstrap 通过一些简单的 HTML 标签和扩展的类即可创建出不同样式的表单。
0x01 样式1
一个登录界面:
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta content="width=device-width, initial-scale=1"> <link href=""> <script src="https://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <script src=""></script> <title>用户登录</title> </head> <body> <div> <form> <div> <label for="UserName">用户名</label> <input type="text" placeholder="用户名"> </div> <div> <label for="PassWord">密 码</label> <input type="password" placeholder="密码"> </div> <div> <label> <input type="checkbox">记住我吗? </label> </div> <div> <input type="button" value="登 录"> </div> </form> </div> </body> </html>
效果如下:
0x02 样式2
如果要将label与文本框在同一行显示,修改如下:
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta content="width=device-width, initial-scale=1"> <link href=""> <script src="https://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <script src=""></script> <title>用户登录</title> </head> <body> <div> <div></div> <div> <div> <h1>用户登录</h1> </div> <form> <div> <div> <label for="UserName">用户名:</label> </div> <div> <input type="text" placeholder="用户名"> </div> </div> <div> <div> <label for="PassWord">密 码:</label> </div> <div> <input type="password" placeholder="密码"> </div> </div> <div> <div></div> <div> <div> <label> <input type="checkbox">记住我吗? </label> </div> </div> </div> <div> <div></div> <div> <input type="button" value="登 录"> </div> </div> </form> </div> <div></div> </div> </body> </html>
效果如下:
0x03 样式3
如果将文本框放在同一行,修改如下:
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta content="width=device-width, initial-scale=1"> <link href=""> <script src="https://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script> <script src=""></script> <title>用户登录</title> </head> <body> <div> <form> <div> <label for="UserName">用户名:</label> <input type="text" placeholder="用户名"> </div> <div> <label for="PassWord">密 码:</label> <input type="password" placeholder="密码"> </div> <div> <div> <label> <input type="checkbox">记住我吗? </label> </div> </div> <div> <input type="button" value="登 录"> </div> </form> </div> </body> </html>
效果如下: