Bootstrap List Groups
In this chapter, we will explain list groups. List components are used to present complex and custom content in a list format. The steps to create a basic list group are as follows:
- To the element
-
Add the class .list-group。
- towards
- Add the class .list-group-item。
The following example demonstrates this:
Example
<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
Try it »
The result is as follows:
Adding Badges to a List Group
We can add a badge component to any list item, and it will automatically position itself on the right. Simply add it inside the
- element. . The following example demonstrates this:
Example
<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"> <span class="badge" New span>24*7 support
li
<li class="list-group-item">Annual renewal cost
li
<li class="list-group-item"> <span class="badge" New span>Discount Offer
li
ul
Try it »
The result is as follows:
Adding Links to List Groups
By using anchor tags instead of list items, we can add links to list groups. We need to use instead of
- elements. The following example demonstrates this:
Example
<a href="" class=">list-group-item active
"
Free domain registration
a
<a href="" class="list-group-item">24*7 support
a
<a href="" class="list-group-item">Free Window hosting space
a
<a href="" class="list-group-item">Number of images
a
<a href="" class="list-group-item">Annual renewal cost
a
Try it »
The result is as follows:
Adding Custom Content to List Groups
We can add any HTML content to the list group with links added above. The following example demonstrates this:
Example
<div class="list-group"> <a href="" class=">list-group-item active
"
<h4 class="list-group-item-heading">Starter Website Package
h4
a
<a href="" class="list-group-item"> <h4 class="list-group-item-heading">Free domain registration
h4
<p class="list-group-item-text">You will register a free domain name through the web page.
p
a
<a href="" class="list-group-item"> <h4 class="list-group-item-heading">24*7 support
h4
<p class="list-group-item-text">We provide 24*7 support.
p
a
div
<div class="list-group"> <a href="" class=">list-group-item active
"
<h4 class="list-group-item-heading">Business Website Package
h4
a
<a href="" class="list-group-item"> <h4 class="list-group-item-heading">Free domain registration
h4
<p class="list-group-item-text">You will register a free domain name through the web page.
p
a
<a href="" class="list-group-item"> <h4 class="list-group-item-heading">24*7 support
h4
<p class="list-group-item-text">We provide 24*7 support.
p
a
div
Try it »
The result is as follows:
Horizontal List
The lists in the examples above are all displayed vertically. If we need a horizontal list, we can implement it with the following code:
Example
.list-group-horizontal
.list-group-item
{
display:
inline-block
;
}
.list-group-horizontal
.list-group-item
{
margin-bottom:
0
;
margin-left:
4
px
;
margin-right:
0
;
}
.list-group-horizontal
.list-group-item
:first-child
{
border-top-right-radius:
0
;
border-bottom-left-radius:
4
px
;
}
.list-group-horizontal
.list-group-item
:last-child
{
border-top-right-radius:
4
px
;
border-bottom-left-radius:
0
;
}
Try it »
The result is as follows: