A panel is a box used to call attention to a web page. It can hold absolutely anything inside of it, so it just depends on what we wish for it to display.
A panel has three major parts:
A panel can be created with these four classes:
.panel
.panel-heading
.panel-body
.panel-footer
A container ( div
) with the class .panel
is used as the parent.
Three containers with the other three classes each are the children’s containers. Each holds the content which they are meant to hold.
<div>
<div></div>
<div></div>
<div></div>
</div>
A panel-group is a group of many panels. It can be created by wrapping many panels inside a parent container with the class .panel-group
.
<div>
<div id="panel1">
<div></div>
<div></div>
<div></div></div>
<div id="panel2>
<div></div>
<div></div>
<div></div>
</div>
</div>
Contextual classes are mainly used to add color to our panel. They are commonly used on the container with class .panel
, which automatically adds color to the panel-heading
. They include:
panel-default
: Adds no color to the panel.panel-success
: Adds a green color to the panel.panel-primary
: Adds blue color to the panel.Let’s look at the example below:
div
with class panel-group
. This container holds all the children’s panels as a group.div
with classes panel
and panel-primary
. This sets up our panel and automatically adds blue color to the header.div
with class panel-heading
. It holds the panel header.div
with class panel-body
. It holds the panel content.div
with class panel-footer
. It holds the panel footer.panel-danger
, which gives it a different color.panel-info
, which gives it a different color.