Bootstrap panel
Bootstrap Panels
This chapter will explain Bootstrap Panels. The Panel component is used to insert DOM components into a box. To create a basic panel, just add class .panel and class .panel-default to the <div> element, as shown in the following example:
Instance
<!DOCTYPE html> <html> <head> <title>Bootstrap 实例 - 默认的面板</title> <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script> </head> <body> <div class="panel panel-default"> <div class="panel-body"> 这是一个基本的面板 </div> </div> </body> </html>
Run Instance»
Click the "Run Instance" button to view the online instance
panel Title
We can add a panel title in the following two ways:
It is easy to add to the panel using the .panel-heading class Title container. to easily add a heading container to your panel.
Use <h1>-<h6> with .panel-title class to add predefined style title.
The following example demonstrates these two methods:
Example
<!DOCTYPE html> <html> <head> <title>Bootstrap 实例 - 面板标题</title> <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script> </head> <body> <div class="panel panel-default"> <div class="panel-heading"> 不带 title 的面板标题 </div> <div class="panel-body"> 面板内容 </div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title"> 带有 title 的面板标题 </h3> </div> <div class="panel-body"> 面板内容 </div> </div> </body> </html>
Running Example »
Click the "Run Example" button to view the online example
Panel footnote
We can add footnotes to the panel, just put the button or subtext in Just put it in a <div> with class .panel-footer. The following example demonstrates this:
Instance
<!DOCTYPE html> <html> <head> <title>Bootstrap 实例 - 面板脚注</title> <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script> </head> <body> <div class="panel panel-default"> <div class="panel-body"> 这是一个基本的面板 </div> <div class="panel-footer">面板脚注</div> </div> </body> </html>
Run Instance»
Click the "Run Instance" button to view Online Example
The panel footer does not inherit the color and border from the contextually colored panel because it is not the content in the foreground.
Panel with contextual color
Use contextual state classespanel-primary, panel-success, panel-info, panel-warning, panel-danger, to Set up a panel with contextual colors. The example is as follows:
Instance
<!DOCTYPE html> <html> <head> <title>Bootstrap 实例 - 带语境色彩的面板</title> <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script> </head> <body> <div class="panel panel-primary"> <div class="panel-heading"> <h3 class="panel-title">面板标题</h3> </div> <div class="panel-body"> 这是一个基本的面板 </div> </div> <div class="panel panel-success"> <div class="panel-heading"> <h3 class="panel-title">面板标题</h3> </div> <div class="panel-body"> 这是一个基本的面板 </div> </div> <div class="panel panel-info"> <div class="panel-heading"> <h3 class="panel-title">面板标题</h3> </div> <div class="panel-body"> 这是一个基本的面板 </div> </div> <div class="panel panel-warning"> <div class="panel-heading"> <h3 class="panel-title">面板标题</h3> </div> <div class="panel-body"> 这是一个基本的面板 </div> </div> <div class="panel panel-danger"> <div class="panel-heading"> <h3 class="panel-title">面板标题</h3> </div> <div class="panel-body"> 这是一个基本的面板 </div> </div> </body> </html>
Run Instance»
Click "Run Instance" "Button to view online examples
Panel with table
In order to create a borderless table in the panel, we can use class .table in the panel . Suppose we have a <div> containing .panel-body, we can add an extra border to the top of the table to separate it. If there is no <div> containing .panel-body, the component moves from the panel header to the table without interruption.
The following example demonstrates this:
Example
<!DOCTYPE html> <html> <head> <title>Bootstrap 实例 - 带表格的面板</title> <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script> </head> <body> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">面板标题</h3> </div> <div class="panel-body"> 这是一个基本的面板 </div> <table class="table"> <th>产品</th><th>价格 </th> <tr><td>产品 A</td><td>200</td></tr> <tr><td>产品 B</td><td>400</td></tr> </table> </div> <div class="panel panel-default"> <div class="panel-heading">面板标题</div> <table class="table"> <th>产品</th><th>价格 </th> <tr><td>产品 A</td><td>200</td></tr> <tr><td>产品 B</td><td>400</td></tr> </table> </div> </body> </html>
Run Instance»
Click the "Run Instance" button to view the online instance
Panel with list group
We can in any panel To contain a list group, create a panel by adding the .panel and .panel-default classes to the <div> element, and add the list group within the panel. You can learn how to create a list group from the List Groups chapter.
Instance
<!DOCTYPE html> <html> <head> <title>Bootstrap 实例 - 带列表组的面板</title> <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script> </head> <body> <div class="panel panel-default"> <div class="panel-heading">面板标题</div> <div class="panel-body"> <p>这是一个基本的面板内容。这是一个基本的面板内容。 这是一个基本的面板内容。这是一个基本的面板内容。 这是一个基本的面板内容。这是一个基本的面板内容。 这是一个基本的面板内容。这是一个基本的面板内容。 </p> </div> <ul class="list-group"> <li class="list-group-item">免费域名注册</li> <li class="list-group-item">免费 Window 空间托管</li> <li class="list-group-item">图像的数量</li> <li class="list-group-item">24*7 支持</li> <li class="list-group-item">每年更新成本</li> </ul> </div> </body> </html>
Run instance»
Click the "Run instance" button to view the online instance