alert

bootstrap5.css

bootstrap5.css
.alert {
  position: relative;
  padding: 1rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  border-radius: 0.25rem;
}
bootstrap5.css
.alert-heading {
  color: inherit;
}
bootstrap5.css
.alert-link {
  font-weight: 700;
}
bootstrap5.css
.alert-dismissible {
  padding-right: 3rem;
}
bootstrap5.css
.alert-dismissible .btn-close {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  padding: 1.25rem 1rem;
}
bootstrap5.css
.alert-primary {
  color: #084298;
  background-color: #cfe2ff;
  border-color: #b6d4fe;
}
bootstrap5.css
.alert-primary .alert-link {
  color: #06357a;
}
bootstrap5.css
.alert-secondary {
  color: #41464b;
  background-color: #e2e3e5;
  border-color: #d3d6d8;
}
bootstrap5.css
.alert-secondary .alert-link {
  color: #34383c;
}
bootstrap5.css
.alert-success {
  color: #0f5132;
  background-color: #d1e7dd;
  border-color: #badbcc;
}
bootstrap5.css
.alert-success .alert-link {
  color: #0c4128;
}
bootstrap5.css
.alert-info {
  color: #055160;
  background-color: #cff4fc;
  border-color: #b6effb;
}
bootstrap5.css
.alert-info .alert-link {
  color: #04414d;
}
bootstrap5.css
.alert-warning {
  color: #664d03;
  background-color: #fff3cd;
  border-color: #ffecb5;
}
bootstrap5.css
.alert-warning .alert-link {
  color: #523e02;
}
bootstrap5.css
.alert-danger {
  color: #842029;
  background-color: #f8d7da;
  border-color: #f5c2c7;
}
bootstrap5.css
.alert-danger .alert-link {
  color: #6a1a21;
}
bootstrap5.css
.alert-light {
  color: #636464;
  background-color: #fefefe;
  border-color: #fdfdfe;
}
bootstrap5.css
.alert-light .alert-link {
  color: #4f5050;
}
bootstrap5.css
.alert-dark {
  color: #141619;
  background-color: #d3d3d4;
  border-color: #bcbebf;
}
bootstrap5.css
.alert-dark .alert-link {
  color: #101214;
}

html bootstrap5 Sample

アラートの背景色:alert-*


  <div class="alert alert-primary" role="alert">alert-primary</div>
  <div class="alert alert-secondary" role="alert">alert-secondary</div>
  <div class="alert alert-success" role="alert">alert-success</div>
  <div class="alert alert-danger" role="alert">alert-danger</div>
  <div class="alert alert-warning" role="alert">alert-warning</div>
  <div class="alert alert-info" role="alert">alert-info</div>
  <div class="alert alert-light" role="alert">alert-light</div>
  <div class="alert alert-dark" role="alert">alert-dark</div>

js アラートを閉じるボタンで消す:alert-bs-dismissible


  <!-- btn-closeで×マーク background: svg -->
  <div class="alert alert-warning alert-dismissible fade show" role="alert">
    右側の「×」マークをクリックするとアラートが閉じます
    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
    </button>
  </div>

アラート内にコンテンツを追加する:alert


  <div class="alert alert-success" role="alert">
    <h4 class="alert-heading">アラートのタイトル</h4>
    <p>アラートの内容</p>
    <p class="mb-0"><a href="#" class="alert-link">詳細内容へ</a></p>
    <p class="mb-0"><a href="#">問い合わせ</a></p>
  </div>