Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Bootstrap Panels

Bootstrap Panels (Panels)

This chapter will explain Bootstrap panels (Panels). The panel component is used to insert DOM components into a box. To create a basic panel, you only need to add to the

element the class .panel and the class .panel-default , as shown in the example below:

Example

<div class=">

panel panel-default

"

<div class="panel-body">

This is a basic panel

div

div

Try it »

The result is as follows:

Panel Heading

We can add a panel heading in the following two ways:

  • Use .panel-heading class can easily add a heading container to the panel.
  • Use the .panel-title from the class take effect

    -

    to add a heading with a predefined style.

The following example demonstrates these two ways:

Example

<div class=">

panel panel-default

"

<div class="panel-heading">

Panel Heading Without a Title

div

<div class="panel-body">

Panel Content

div

div

<div class=">

panel panel-default

"

<div class="panel-heading">
<h3 class="panel-title">

Panel Heading With a Title

h3

div

<div class="panel-body">

Panel Content

div

div

Try it »

The result is as follows:

Panel Footer

We can add a footer to the panel by simply putting buttons or subtext inside a div with class .panel-footer 's

. The following example demonstrates this:

Example

<div class=">

panel panel-default

"

<div class="panel-body">

This is a basic panel

div

<div class="panel-footer">

Panel Footer

div

div

Try it »

The result is as follows:

Panel footers do not inherit the color and border from contextual panels, because they are not part of the foreground content.

Contextual Panels

Use the contextual state classes panel-primary、panel-success、panel-info、panel-warning、panel-dangerto set up contextual panels, as shown in the example below:

Example

<div class=">

panel panel-primary

"

<div class="panel-heading">
<h3 class="panel-title">

Panel Heading

h3

div

<div class="panel-body">

This is a basic panel

div

div

<div class=">

panel panel-success

"

<div class="panel-heading">
<h3 class="panel-title">

Panel Heading

h3

div

<div class="panel-body">

This is a basic panel

div

div

<div class=">

panel panel-info

"

<div class="panel-heading">
<h3 class="panel-title">

Panel Heading

h3

div

<div class="panel-body">

This is a basic panel

div

div

<div class=">

panel panel-warning

"

<div class="panel-heading">
<h3 class="panel-title">

Panel Heading

h3

div

<div class="panel-body">

This is a basic panel

div

div

<div class=">

panel panel-danger

"

<div class="panel-heading">
<h3 class="panel-title">

Panel Heading

h3

div

<div class="panel-body">

This is a basic panel

div

div

Try it »

The result is as follows:

Panels with Tables

To create a borderless table in a panel, we can use the class .tablein the panel. Suppose there is a

Contains .panel-body, we can add an extra border to the top of the table to separate it. If the .panel-body 's
is not included, the component will move from the panel heading to the table without a break.

The following example demonstrates this:

Example

<div class=">

panel panel-default

"

<div class="panel-heading">
<h3 class="panel-title">

Panel Heading

h3

div

<div class="panel-body">

This is a basic panel

div

<table class="table">
<th Product th>
<th Price th>
<tr>
<td>

Product A

td

<

td

200

td

tr

<

tr

<

td

Product B

td

<

td

400

td

tr

table

div

<

div

class

=

"

panel panel-default

"

<div class="panel-heading">

Panel Heading

div

<table class="table">
<th Product th>
<th Price th>
<tr>
<td>

Product A

td

<

td

200

td

tr

<

tr

<

td

Product B

td

<

td

400

td

tr

table

div

Try it »

The result is as follows:

Panels with List Groups

We can include a list group in any panel by adding the

element. .panel and .panel-default class to create the panel and adding the list group inside it. You can learn from the List Group chapter how to create a list group.

Example

<div class=">

panel panel-default

"

<div class="panel-heading">

Panel Heading

div

<div class="panel-body">
<p>

This is a basic panel content. This is a basic panel content. This is a basic panel content. This is a basic panel content. This is a basic panel content. This is a basic panel content. This is a basic panel content. This is a basic panel content.

p

div

<ul class="list-group">
<li class="list-group-item">

Free domain registration

li

<li class="list-group-item">

Free Window hosting space

li

<li class="list-group-item">

Number of images

li

<li class="list-group-item">

24*7 support

li

<li class="list-group-item">

Annual renewal cost

li

ul

div

Try it »

The result is as follows: