Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Bootstrap 5 警报


警报

Bootstrap 5 提供了一种简单的方法来创建预定义的警报消息。

警报使用 .alert 类创建,后跟一个上下文类 .alert-success.alert-info.alert-warning.alert-danger.alert-primary.alert-secondary.alert-light.alert-dark

示例

<div class="alert alert-success">
  <strong>成功!</strong> 表示成功或积极的操作。
</div>
亲自尝试 »


警报链接

在警报框内的任何链接中添加 .alert-link 类,以创建“匹配颜色的链接”。

示例

<div class="alert alert-success">
  <strong>成功!</strong> 您应该 <a href="#" class="alert-link">阅读此消息</a>。
</div>
亲自尝试 »

关闭警报

成功! 此警报框可能表示成功或积极的操作。

要关闭警报消息,请在警报容器中添加 .alert-dismissible 类。然后在链接或按钮元素中添加 class="btn-close"data-bs-dismiss="alert"(当您单击此按钮时,警报框将消失)。

示例

<div class="alert alert-success alert-dismissible">
  <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
  <strong>成功!</strong> 此警报框可能表示成功或积极的操作。
</div>
亲自尝试 »

动画警报

.fade.show 类在关闭警报消息时添加淡出效果。

示例

<div class="alert alert-danger alert-dismissible fade show">
亲自尝试 »


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.