99re热视频这里只精品,久久久天堂国产精品女人,国产av一区二区三区,久久久精品成人免费看片,99久久精品免费看国产一区二区三区

Bootstrap5 信息提示框

2023-06-21 15:07 更新

Bootstrap 5 可以很容易實現(xiàn)信息提示框。


提示框可以使用 .alert 類, 后面加上 .alert-success, .alert-info, .alert-warning, .alert-danger, .alert-primary, .alert-secondary, .alert-light 或 .alert-dark 類來實現(xiàn):

<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap5 實例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link  rel="external nofollow" target="_blank"  rel="stylesheet">
  <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
</head>
<body>

<div class="container mt-3">
  <h2>提示框</h2>
  <p>提示框可以使用 .alert 類, 后面加上指定特定意義的顏色類來實現(xiàn):</p>
  <div class="alert alert-success">
    <strong>成功!</strong> 指定操作成功提示信息。
  </div>
  <div class="alert alert-info">
    <strong>信息!</strong> 請注意這個信息。
  </div>
  <div class="alert alert-warning">
    <strong>警告!</strong> 設置警告信息。
  </div>
  <div class="alert alert-danger">
    <strong>錯誤!</strong> 失敗的操作
  </div>
  <div class="alert alert-primary">
    <strong>首選!</strong> 這是一個重要的操作信息。
  </div>
  <div class="alert alert-secondary">
    <strong>次要的!</strong> 顯示一些不重要的信息。
  </div>
  <div class="alert alert-dark">
    <strong>深灰色!</strong> 深灰色提示框。
  </div>
  <div class="alert alert-light">
    <strong>淺灰色!</strong>淺灰色提示框。
  </div>
</div>

</body>
</html>

提示框添加鏈接

提示框中在鏈接的標簽上添加 alert-link 類來設置匹配提示框顏色的鏈接:

<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap5 實例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link  rel="external nofollow" target="_blank"  rel="stylesheet">
  <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
</head>
<body>

<div class="container mt-3">
  <h2>提示框添加鏈接</h2>
  <p>提示框中在鏈接的標簽上添加 alert-link 類來設置匹配提示框顏色的鏈接:</p>
  <div class="alert alert-success">
    <strong>成功!</strong> 你應該認真閱讀 <a href="#" class="alert-link">這條信息</a>。
  </div>
  <div class="alert alert-info">
    <strong>信息!</strong> 你應該認真閱讀 <a href="#" class="alert-link">這條信息</a>。
  </div>
  <div class="alert alert-warning">
    <strong>警告!</strong> 你應該認真閱讀 <a href="#" class="alert-link">這條信息</a>。
  </div>
  <div class="alert alert-danger">
    <strong>錯誤!</strong> 你應該認真閱讀 <a href="#" class="alert-link">這條信息</a>。
  </div>
  <div class="alert alert-primary">
    <strong>首選!</strong> 你應該認真閱讀 <a href="#" class="alert-link">這條信息</a>。
  </div>
  <div class="alert alert-secondary">
    <strong>次要的!</strong> 你應該認真閱讀 <a href="#" class="alert-link">這條信息</a>。
  </div>
  <div class="alert alert-dark">
    <strong>深灰色!</strong>你應該認真閱讀 <a href="#" class="alert-link">這條信息</a>。
  </div>
  <div class="alert alert-light">
    <strong>灰色!</strong> 你應該認真閱讀 <a href="#" class="alert-link">這條信息</a>。
  </div>
</div>

</body>
</html>

關閉提示框

我們可以在提示框中的 div 中添加 .alert-dismissible 類,然后在關閉按鈕的鏈接上添加 class="btn-close" 和 data-bs-dismiss="alert" 類來設置提示框的關閉操作。

<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap5 實例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link  rel="external nofollow" target="_blank"  rel="stylesheet">
  <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
</head>
<body>

<div class="container mt-3">
  <h2>關閉提示框</h2>
  <p>我們可以在提示框中的 div 中添加 .alert-dismissible 類,然后在關閉按鈕的鏈接上添加 class="btn-close" 和 data-bs-dismiss="alert" 類來設置提示框的關閉操作。</p>
  <div class="alert alert-success alert-dismissible">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>成功!</strong> 指定操作成功提示信息。
  </div>
  <div class="alert alert-info alert-dismissible">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>信息!</strong> 請注意這個信息。
  </div>
  <div class="alert alert-warning alert-dismissible">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>警告!</strong> 設置警告信息。
  </div>
  <div class="alert alert-danger alert-dismissible">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>錯誤!</strong> 失敗的操作。
  </div>
  <div class="alert alert-primary alert-dismissible">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>首選!</strong> 這是一個重要的操作信息。
  </div>
  <div class="alert alert-secondary alert-dismissible">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>次要的!</strong> 顯示一些不重要的信息。
  </div>
  <div class="alert alert-dark alert-dismissible">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>深灰色!</strong> 深灰色提示框。
  </div>
  <div class="alert alert-light alert-dismissible">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>淺灰色!</strong>淺灰色提示框。
  </div>
</div>

</body>
</html>

提示框動畫

.fade 和 .show 類用于設置提示框在關閉時的淡出和淡入效果:

<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap5 實例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link  rel="external nofollow" target="_blank"  rel="stylesheet">
  <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js" rel="external nofollow"  rel="external nofollow"  rel="external nofollow"  rel="external nofollow" ></script>
</head>
<body>

<div class="container mt-3">
  <h2>提示框動畫</h2>
  <p>.fade 和 .show 類用于設置提示框在關閉時的淡出和淡入效果:</p>
  <div class="alert alert-success alert-dismissible fade show">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>成功!</strong> 指定操作成功提示信息。
  </div>
  <div class="alert alert-info alert-dismissible fade show">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>信息!</strong> 請注意這個信息。
  </div>
  <div class="alert alert-warning alert-dismissible fade show">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>警告!</strong> 設置警告信息。
  </div>
  <div class="alert alert-danger alert-dismissible fade show">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>錯誤!</strong> 失敗的操作。
  </div>
  <div class="alert alert-primary alert-dismissible fade show">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>首選!</strong> 這是一個重要的操作信息。
  </div>
  <div class="alert alert-secondary alert-dismissible fade show">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>次要的!</strong> 顯示一些不重要的信息。
  </div>
  <div class="alert alert-dark alert-dismissible fade show">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>深灰色!</strong> 深灰色提示框。
  </div>
  <div class="alert alert-light alert-dismissible fade show">
    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
    <strong>淺灰色!</strong>淺灰色提示框。
  </div>
</div>

</body>
</html>
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號