Pens

Floating Glassmorphism Island Header

UI Component bởi acmatvjrus
Mở Studio
<div class="header-preview-wrapper">
  <header class="glass-island-header">
    <a href="#" class="brand-logo">
      <span class="logo-dot"></span>
      <span class="logo-text">Aura<strong>Flow</strong></span>
    </a>
    <nav class="nav-menu">
      <a href="#" class="nav-item active">Trang chủ</a>
      <a href="#" class="nav-item">Sản phẩm</a>
      <a href="#" class="nav-item">Giải pháp</a>
      <a href="#" class="nav-item">Bảng giá</a>
    </nav>
    <div class="nav-actions">
      <a href="#" class="btn-subtle">Đăng nhập</a>
      <a href="#" class="btn-pill-primary">Bắt đầu ngay</a>
    </div>
  </header>
  <div class="mock-hero">
    <span class="badge-pill">✨ Phiên bản 2.4 đã sẵn sàng</span>
    <h1>Kiến tạo trải nghiệm Web đỉnh cao</h1>
    <p>Giao diện thanh điều hướng kính mờ đa chiều cho sản phẩm hiện đại.</p>
  </div>
</div>
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at 50% 0%, #1e3a34 0%, #0d1615 60%, #080c0c 100%);
  color: #f3f4f6;
  min-height: 100vh;
}
.header-preview-wrapper {
  padding: 24px 20px;
  min-height: 100vh;
  box-sizing: border-box;
}
.glass-island-header {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  position: sticky;
  top: 20px;
  z-index: 100;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.glass-island-header:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(16, 163, 122, 0.35);
  box-shadow: 0 24px 48px -12px rgba(16, 163, 122, 0.2);
}
.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.logo-dot {
  width: 12px;
  height: 12px;
  background: #10a37a;
  border-radius: 50%;
  box-shadow: 0 0 14px #10a37a;
}
.logo-text strong {
  color: #34d399;
}
.nav-menu {
  display: flex;
  gap: 6px;
}
.nav-item {
  color: #9ca3af;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 9999px;
  transition: all 0.2s;
}
.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.btn-subtle {
  color: #d1d5db;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 14px;
  transition: color 0.2s;
}
.btn-subtle:hover { color: #fff; }
.btn-pill-primary {
  background: #10a37a;
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: 9999px;
  box-shadow: 0 4px 14px rgba(16, 163, 122, 0.4);
  transition: all 0.2s;
}
.btn-pill-primary:hover {
  background: #0d8b67;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 163, 122, 0.55);
}
.mock-hero {
  text-align: center;
  margin-top: 80px;
  padding: 20px;
}
.badge-pill {
  display: inline-block;
  padding: 6px 14px;
  background: rgba(16, 163, 122, 0.15);
  border: 1px solid rgba(16, 163, 122, 0.3);
  color: #34d399;
  border-radius: 9999px;
  font-size: 0.82rem;
  margin-bottom: 20px;
}
.mock-hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin: 0 0 16px;
  letter-spacing: -0.03em;
}
.mock-hero p {
  color: #9ca3af;
  font-size: 1.1rem;
  margin: 0;
}
@media (max-width: 768px) {
  .nav-menu, .btn-subtle { display: none; }
}
// Floating Island Interactive Scroll Effect
window.addEventListener("scroll", () => {
  const header = document.querySelector(".glass-island-header");
  if (!header) return;
  if (window.scrollY > 30) {
    header.style.transform = "scale(0.98)";
    header.style.boxShadow = "0 25px 50px -12px rgba(0, 0, 0, 0.7)";
  } else {
    header.style.transform = "scale(1)";
  }
});
Đã sao chép vào bộ nhớ tạm!