We often see certain alerts on some websites before or after completing an action. These alert messages are highlighted texts that are important to take in consideration while performing a process. Bootstrap allows showing these alert messages on the website using predefined classes.
The .alert class followed by contextual classes are used to display the alert message on website. The alert classes are: .alert-success, .alert-info, .alert-warning, .alert-danger, .alert-primary, .alert-secondary, .alert-light and .alert-dark.
<div class="alert> Contents... <div>
Closing Alerts: The .alert-dismissible class is used within .container class to close the alert message. Then use class=”close” and data-dismiss=”alert” to link a button element.
<div class="alert alert_type alert-dismissible"> <button type="button" class="close" data-dismiss="alert">x</button> Alert message <div>
Animated Alerts: The .fade and .show classes are used to add the fading effect of animation when closing the alert message.
<div class="alert alert_type alert-dismissible fade show"> <button type="button" class="close" data-dismiss="alert">x</button> Alert message <div>
- Bootstrap (Part-7) | Alerts , Wells, Pagination and Pager
- Include Bootstrap in AngularJS using ng-bootstrap
- Bootstrap 4 | Jumbotron
- Bootstrap 4 | Popover
- Bootstrap | Spinners Set-2
- Bootstrap 4 | Buttons
- Bootstrap | Spinners Set-1
- Bootstrap 4 | Colors
- Bootstrap 4 | Badges
- Bootstrap 4 | Images
- Bootstrap 4 | Spinners
- Bootstrap 4 | Tables
- Clearfix in Bootstrap
- Bootstrap 4 | Introduction
- Bootstrap 4 | Typography
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.