bootstrap defines a simple and easy-to-use style for us. We only need very little style specification to complete a simple and elegant page display.
This article mainly introduces the following basic controls:
1. table
2. form
3. button
1. Tables are still used to represent tables using <table><thead><tbody><ttr><th><td>. There are the following classes to control the properties of the table. The table style will fill the parent container by default.
<div> <div> <div> <table> <tr> <th>Title 1</th> <th>Title 2</th> <th>Title 3</th> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> <td>4</td> <td>5</td> <td>6</td> </tr> </table> </div> </div> </div> </div> </table> </div> </div> </div> </table> </div> </div> </tv> </tr> </table> </div> </div> </tv> </tr> </table> </div> </div> </tv> </tr>
Wrap any .table in .table-responsive creates a responsive table that scrolls horizontally on a small screen device (less than 768px). When the screen is larger than 768px width, the horizontal scroll bar disappears.
2. Form form, as defined in several styles
The lac and controls should be wrapped with a form-group div. The default form is as follows
<div> <form> <div> <label for="exampleInputEmail1">Email address</label> <input type="email" id="exampleInputEmail1" placeholder="Enter email"> </div> <div> <label for="exampleInputPassword1">Password</label> <input type="password" id="exampleInputPassword1" placeholder="Password"> </div> <div> <label> <input type="checkbox"> Check me out </label> </div> <button type="submit">Submit</button> </form> </div>
Inline form, specify the sr-only category for labels, and can hide the labels, but the lable must not be omitted.
<div> <form> <div> <label for="exampleInputEmail1">Email address</label> <input type="email" id="exampleInputEmail1" placeholder="Enter email"> </div> <div> <label for="exampleInputPassword1">Password</label> <input type="password" id="exampleInputPassword1" placeholder="Password"> </div> <div> <label> <input type="checkbox"> Check me out </label> </div> <button type="submit">Submit</button> </form> </div>
Forms of horizontal type , you must specify the length for latable and tag groups, and use the layout of the grid system. label is aligned right, label group is aligned left.
<div> <form> <div> <label for="exampleInputEmail1">Email address</label> <div> <input type="email" id="exampleInputEmail1" placeholder="Enter email"> </div> </div> <div> <label for="exampleInputPassword1">Password</label> <div> <input type="password" id="exampleInputPassword1" placeholder="Password"> </div> </div> <div> <label> <input type="checkbox"> Check me out </label> </div> <button type="submit">Submit</button> </form> </div>
form form verification, bootstrap3 supports custom verification of forms. Adding req uired means that the form is required, node.setCustomValidity can set the form's custom verification
<div> <form> <div> <label for="exampleInputEmail1">Email address</label> <div> <input type="email" id="exampleInputEmail1" placeholder="Enter email" required> </div> </div> <div> <label for="password1">Password</label> <div> <input type="password" id="password1" placeholder="Password" required onchange="checkPassword()"> </div> </div><div> <label for="password2" onchange="checkPassword()"> Password2</label> <div> <input type="password" id="password2" placeholder="Password2" required> </div> </div> <div> <label> <input type="checkbox"> Check me out </label> </div> <button type="submit">Submit</button> </form> </div> <script> function checkPassword() { var pwd1 = $("#password1").val(); var pwd2 = $("#password2").val(); if (pwd1 != pwd2) { document.getElementById("password1").setCustomValidity("The password entered twice is inconsistent"); } else { document.getElementById("password1").setCustomValidity(""); } } </script>3. The style of button
Use .btn-lg, .btn-sm, and .btn-xs to obtain buttons of different sizes. Adding .btn-block to the button can make it fill 100% of the width of the parent node, and the button also becomes a block-level element, and add button class to the <a>, <button> or <input> elements.
<div> <button type="button">Default</button> <button type="button">Primary</button> <button type="button">Success</button> <button type="button">Info</button> <button type="button">Warning</button> <button type="button">Warning</button> <button type="button">Danger</button> <button type="button">Link</a> <button type="submit">Button</button> <input type="button" value="Input"> <input type="submit" value="Submit"> </div>
If you still want to learn in depth, you can click here to learn and attach two exciting topics to you: Bootstrap learning tutorial Bootstrap practical tutorial
The above is all about this article, I hope it will be helpful to everyone's learning.