Canlı Önizleme
Nasıl Kullanılır?
Sidebar'ın pozisyonu bu örnekte 'absolute' verilmiştir. Tüm sayfayı kaplaması için CSS içinden .custom-sidebar top:0, left: -250px, position: fixed; ve height: 100vh; gibi değerlerini kendi sitenize göre ayarlamanız gerekir.
Kaynak Kodlar
HTML
<!-- Hamburger Butonu -->
<button class="custom-hamburger" onclick="toggleCustomSidebar()">
<span></span>
<span></span>
<span></span>
</button>
<!-- Açılır Menü -->
<div class="custom-sidebar" id="mySidebar">
<div class="sidebar-header">Geçmiş Sohbetler</div>
<a href="#"><i class="fas fa-comment-dots"></i> Proje Fikri</a>
<a href="#"><i class="fas fa-comment-dots"></i> Hata Çözümü</a>
<a href="#"><i class="fas fa-comment-dots"></i> Kod İncelemesi</a>
</div>
CSS
/* Buton Stili */
.custom-hamburger { position: relative; z-index: 100; width: 40px; height: 40px; background: rgba(255,255,255,0.1); border: none; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px; transition: 0.3s; }
.custom-hamburger span { width: 20px; height: 2px; background: #fff; transition: 0.4s; }
.custom-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.custom-hamburger.open span:nth-child(2) { opacity: 0; }
.custom-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
/* Sidebar Stili */
.custom-sidebar { position: absolute; top:0; left: -250px; width: 250px; height: 350px; background: #2a2a35; box-shadow: 5px 0 15px rgba(0,0,0,0.5); border-radius: 10px; transition: 0.4s cubic-bezier(0.68,-0.55,0.265,1.55); padding-top: 60px; font-family: 'Inter', sans-serif; overflow: hidden; z-index: 90; }
.custom-sidebar.active { left: 0; }
.sidebar-header { margin-bottom: 20px; padding: 0 20px; color: #a0a0b0; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; }
.custom-sidebar a { display: block; padding: 12px 20px; color: #fff; text-decoration: none; font-size: 15px; transition: 0.3s; }
.custom-sidebar a i { margin-right: 10px; color: #6C5CE7; }
.custom-sidebar a:hover { background: rgba(108,92,231,0.2); border-left: 4px solid #6C5CE7; padding-left: 16px; }
JavaScript
function toggleCustomSidebar() {
document.querySelector('.custom-hamburger').classList.toggle('open');
document.getElementById('mySidebar').classList.toggle('active');
}