モーダル
JavaScript

Alert Banner

上部からスライドインするアラートバナー。

HTML
<div class="alert-banner" id="alert">
  <span style="font-size:13px">&#9888; Your trial expires in 3 days.</span>
  <button class="alert-close" id="alert-close">&times;</button>
</div>
<div style="text-align:center;padding-top:40px">
  <button class="alert-trigger" id="alert-show">Show Alert</button>
</div>
CSS
.alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #fefce8;
  border-bottom: 1px solid #fde68a;
  font-size: 13px;
  color: #92400e;
  font-weight: 500;
  transform: translateY(-100%);
  opacity: 0;
  transition: all .35s cubic-bezier(.16,1,.3,1);
}
.alert-banner.show {
  transform: translateY(0);
  opacity: 1;
}
.alert-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #92400e;
  cursor: pointer;
  padding: 0 4px;
}
.alert-trigger {
  padding: 8px 20px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
JavaScript
const banner = document.getElementById('alert');
document.getElementById('alert-show').addEventListener('click', () => {
  banner.classList.add('show');
});
document.getElementById('alert-close').addEventListener('click', () => {
  banner.classList.remove('show');
});