Bootstrap Alerts
This chapter explains Alerts and the classes Bootstrap provides for alerts. Alerts give users a way to define message styles. They provide contextual feedback for typical user actions.
You can add an optional close button to an alert. To create an inline dismissible alert, use Alerts jQuery Plugin。
You can add a basic alert by creating a
Example
<div class=">alert alert-success
"
Success! Your submission was completed successfully.
div
<div class=">alert alert-info
"
Info! Please note this information.
div
<div class=">alert alert-warning
"
Warning! Please do not submit.
div
<div class=">alert alert-danger
"
Error! Please make some changes.
div
Try it »
The result is as follows:
Dismissible Alerts
The steps to create a dismissible alert are as follows:
- Add a basic alert by creating a
, and adding a .alert class and one of the four contextual classes (namely ** .alert-success, .alert-info, .alert-warning, .alert-danger**).
- At the same time, add the optional
class to the above element. .alert-dismissable。
- Add a close button.
The following example demonstrates this:
Example
<div class=">alert alert-success alert-dismissable
"
<button type="button" class="close" data-dismiss="alert" aria-hidden="true" ×button>Success! Your submission was completed successfully.
div
<div class=">alert alert-info alert-dismissable
"
<button type="button" class="close" data-dismiss="alert" aria-hidden="true" ×button>Info! Please note this information.
div
<div class=">alert alert-warning alert-dismissable
"
<button type="button" class="close" data-dismiss="alert" aria-hidden="true" ×button>Warning! Please do not submit.
div
<div class=">alert alert-danger alert-dismissable
"
<button type="button" class="close" data-dismiss="alert" aria-hidden="true" ×button>Error! Please make some changes.
div
Make sure to use an element with the data-dismiss="alert" data attribute
Try it »
The result is as follows:
Links in Alerts
The steps to create links in Alerts are as follows:
- Add a basic alert by creating a
, and adding a .alert class and one of the four contextual classes (namely ** .alert-success, .alert-info, .alert-warning, .alert-danger**).
- Use .alert-link class to quickly provide links with matching colors.
Example
<div class=">alert alert-success
"
<a href="" class="alert-link">Success! Your submission was completed successfully.
a
div
<div class=">alert alert-info
"
<a href="" class="alert-link">Info! Please note this information.
a
div
<div class=">alert alert-warning
"
<a href="" class="alert-link">Warning! Please do not submit.
a
div
<div class=">alert alert-danger
"
<a href="" class="alert-link">Error! Please make some changes.
a
div
Try it »
The result is as follows:
Make sure to use an element with the data-dismiss="alert" data attribute