Lesson 9: Alerts in Bootstrap 5

What is Bootstrap 5 Alert? Bootstrap 5 alerts are a crucial component in web and application development. Heres everything you need to know about alerts in Bootstrap 5.

What is Bootstrap 5 Alert? Bootstrap 5 alert is a crucial component in web and application development. Here's everything you need to know about alerts in Bootstrap 5 .

 

Basic Alert

You can add a basic alert by creating a block with additional classes .alertcombined with the 6 context classes .alert-success, .alert-info, .alert-warning, .alert-danger, .alert-primary, .alert-secondary, .alert-lightor.alert-dark

Let's try the following example:

 Ví dụ Bootstrap - TipsMake.com.com 

Alert Bootstrap

The alert is created with the .alert class, which includes a contextual color class:

 Thành công! Dùng cho một hành động thành công hoặc tích cực. Thông tin! Chỉ ra sự thay đổi thông tin hoặc hành động có tính trung lập. Cảnh báo! Dùng cho một cảnh báo có thể cần chú ý. Nguy hiểm! Dùng cho một hành động nguy hiểm hoặc có khả năng tiêu cực. Quan trọng! Dùng cho một hành động quan trọng. Thứ cấp! Dùng cho một hành động ít quan trọng hơn. Cảnh báo! Cảnh báo có màu xám đen. Cảnh báo khác! Cảnh báo xám nhạt. 

 

We will receive warnings like the following on the web:

Insert a link in the alert.

When you need to add a link to the alert, you add a class .alert-linkto the link inside the alert box, then the link will have a color that matches the alert's color, as in this example:

 Ví dụ Bootstrap - TipsMake.com.com 

Add a link to Alert

 Thành công! Bạn nên đọc thông báo này. Thông tin! Bạn nên đọc thông báo này. Cảnh báo! Bạn nên đọc thông báo này. Nguy hiểm! Bạn nên đọc thông báo này. Quan trọng! Bạn nên đọc thông báo này. Thứ cấp! Bạn nên đọc thông báo này. Nền tối! Bạn nên đọc thông báo này. Nền sáng! Bạn nên đọc thông báo này. 

 

When you hover your mouse over the warning link, you will see the link appear at the bottom of the browser window as shown in the image:

Close the alert.

To close the alert message, you add a class .alert-dismissibleto the alert container. Then add the class="close" and data-dismiss="alert" to the link or button element (the button that you click to close the alert). We will learn more about buttons in Bootstrap in the next lesson.

Here's an example of closing warnings in Bootstrap 5:

 Ví dụ Bootstrap - TipsMake.com.com 

Close the alert.

  Thành công! TipsMake.com.com chúc mừng bạn đã học xong Bootstrap.  Thông tin! Bạn sẽ học được nhiều bài học hay về Bootstrap trên QuanTriMang.com. 

When you click the button xon the right, the alert will be closed:

Create dynamic alerts

If you add the class .fade, .showit will create a fade-out effect when the alert closes. The usage is the same as above; you add fade and show to the tag div. For example, if you need to close an alert notifying you that an action has been successfully completed, it would look like this:

 

 

Then we have this .html file:

 Ví dụ Bootstrap - TipsMake.com.com 

Close the alert.

  Thành công! Chúc mừng bạn đã học xong Bootstrap. 

This code produces the same result as above; the effect only appears when you click the close button, so I didn't take a screenshot.

Note : In Bootstrap 4, you will need to add an × character between the opening and closing Button tags. The closing button in Bootstrap 4 will then look like this:

× (×) is a very commonly used HTML entity for closing buttons instead of the letter x.

Icon

Similarly, you can use the flexbox and Icon widgets in Bootstrap to create alerts with icons. Depending on the icon and content, you may want to add more widgets or customization options.

For example:

 Bootstrap Example Ví dụ về cảnh báo kèm icon 

You need more than one icon for your alert. Consider using more Bootstrap icons and creating an internal SVG icon for easy referencing.

 Bootstrap Example Cảnh báo kèm icon Cảnh báo kèm icon Cảnh báo kèm icon Cảnh báo kèm icon 

By the end of this article, you should now be able to customize the format of a warning/notification on your website to alert users. Keep following our next series of articles!

Related posts
Other Program articles
  • Lesson 8: Jumbotron in Bootstrap 5

    trong bootstrap, jumbotron là một box màu xám chứa văn bản, với mục đích là tăng thêm sự chú ý cho văn bản trong đó. khi cảm thấy văn bản/thông tin nào thật quan trọng, cần phải làm cho nó xuất hiện thật lớn, thật gây chú ý, bạn chỉ cần viết nó trong jumbotron.
  • Lesson 6: Tables in Bootstrap 5

    table trong bootstrap là gì? cách tạo table trong bootstrap như thế nào? hãy cùng tipsmake.com.com tìm hiểu nhé!
  • Lesson 5: Colors in Bootstrap 5

    màu trong bootstrap được sử dụng như thế nào? Ở bài viết này, hãy cùng nhau tìm hiểu mọi điều về màu bootstrap nhé!
  • Lesson 4: Typography in Bootstrap 5

    căn giữa bootstrap 5 không khó. Đó là một phần trong typography. dưới đây là mọi điều bạn cần biết về typography trong bootstrap 5.
  • Lesson 3: Grid System in Bootstrap 5

    col trong bootstrap chỉ là một phần của hệ thống grid. bài viết sẽ cung cấp cho bạn mọi kiến thức cơ bản cần biết về grid system của css.
  • Lesson 1: What is Bootstrap 5? How to get started?

    cách sử dụng bootstrap 5 không quá khó. bài viết sẽ cho bạn biết bootstrap 5 là gì và cách dùng bootstrap 5.
Category

System

Windows XP

Windows Server 2012

Windows 8

Windows 7

Windows 10

Wifi tips

Virus Removal - Spyware

Speed ​​up the computer

Server

Security solution

Mail Server

LAN - WAN

Ghost - Install Win

Fix computer error

Configure Router Switch

Computer wallpaper

Computer security

Mac OS X

Mac OS System software

Mac OS Security

Mac OS Office application

Mac OS Email Management

Mac OS Data - File

Mac hardware

Hardware

USB - Flash Drive

Speaker headset

Printer

PC hardware

Network equipment

Laptop hardware

Computer components

Advice Computer

Game

PC game

Online game

Mobile Game

Pokemon GO

information

Technology story

Technology comments

Quiz technology

New technology

British talent technology

Attack the network

Artificial intelligence

Technology

Smart watches

Raspberry Pi

Linux

Camera

Basic knowledge

Banking services

SEO tips

Science

Strange story

Space Science

Scientific invention

Science Story

Science photo

Science and technology

Medicine

Health Care

Fun science

Environment

Discover science

Discover nature

Archeology

Life

Travel Experience

Tips

Raise up child

Make up

Life skills

Home Care

Entertainment

DIY Handmade

Cuisine

Christmas

Application

Web Email

Website - Blog

Web browser

Support Download - Upload

Software conversion

Social Network

Simulator software

Online payment

Office information

Music Software

Map and Positioning

Installation - Uninstall

Graphic design

Free - Discount

Email reader

Edit video

Edit photo

Compress and Decompress

Chat, Text, Call

Archive - Share

Electric

Water heater

Washing machine

Television

Machine tool

Fridge

Fans

Air conditioning

Program

Unix and Linux

SQL Server

SQL

Python

Programming C

PHP

NodeJS

MongoDB

jQuery

JavaScript

HTTP

HTML

Git

Database

Data structure and algorithm

CSS and CSS3

C ++

C #

AngularJS

Mobile

Wallpapers and Ringtones

Tricks application

Take and process photos

Storage - Sync

Security and Virus Removal

Personalized

Online Social Network

Map

Manage and edit Video

Data

Chat - Call - Text

Browser and Add-on

Basic setup