在 Bootstrap 中创建解除警报

bootstrapweb developmentcss framework更新于 2026/2/12 17:16:17

创建解除警报 −

  • 通过创建包装器 <div> 并添加 .alert 类以及四个上下文类之一(例如 .alert-success、.alert-info 等)来添加基本警报。
  • 同时将可选的 .alert-dismissable 添加到上述 <div> 类中。
  • 添加一个关闭按钮。

您可以尝试运行以下代码来创建解除警报 −

示例

<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "alert alert-success alert-dismissable">
         <button type = "button" class = "close" data-dismiss = "alert" aria-hidden = "true">
            ×
         </button>
         Success! Well done its submitted.
      </div>
      <div class = "alert alert-info alert-dismissable">
         <button type = "button" class = "close" data-dismiss = "alert" aria-hidden = "true">
            ×
         </button>
         Info! Take this info.
      </div>
   </body>
</html>

相关文章