Create a flexible, wrapped grid of cards with responsive design.
by anoopsuda
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Left Slider Menu (Overlap)</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<!-- Hidden checkbox acts as toggle -->
<input type="checkbox" id="menu-toggle" />
<!-- Hamburger Icon -->
<label for="menu-toggle" class="hamburger">☰</label>
<!-- Sidebar -->
<aside class="sidebar">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">Contact</a></li>
</ul>
</aside>
<!-- Overlay (click outside to close) -->
<label for="menu-toggle" class="overlay"></label>
<!-- Main Page Content -->
<main class="content">
<h1>Welcome to My Simple Page</h1>
<p>This is your main content area. Click the ☰ icon to open the sidebar menu.</p>
</main>
</body>
</html>
CSS
/* Reset and base styling */
body {
margin: 0;
font-family: Arial, sans-serif;
background-color: #f4f4f4;
overflow-x: hidden;
}
/* Hide the checkbox input */
#menu-toggle {
display: none;
}
/* Hamburger Icon */
.hamburger {
font-size: 26px;
cursor: pointer;
padding: 12px 16px;
color: #333;
background: #fff;
position: fixed;
top: 15px;
left: 15px;
border-radius: 8px;
box-shadow: 0 2px 6px rgba(0,0,0,0.2);
z-index: 1001;
transition: background 0.3s ease;
}
.hamburger:hover {
background: #eee;
}
/* Sidebar Menu */
.sidebar {
position: fixed;
top: 0;
left: -300px; /* hidden by default */
width: 300px;
height: 100vh;
background-color: #333;
color: white;
transition: left 0.3s ease;
z-index: 1002;
padding-top: 60px;
box-shadow: 2px 0 8px rgba(0,0,0,0.3);
}
.sidebar ul {
list-style: none;
margin: 0;
padding: 0;
}
.sidebar li {
border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar a {
display: block;
color: white;
text-decoration: none;
padding: 15px 20px;
transition: background 0.2s;
}
.sidebar a:hover {
background: rgba(255,255,255,0.1);
}
/* Overlay when sidebar is open */
.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.4);
opacity: 0;
pointer-events: none;
transition: opacity 0.3s ease;
z-index: 1000;
}
/* Toggle sidebar visibility */
#menu-toggle:checked + .hamburger + .sidebar {
left: 0;
}
/* Show overlay when sidebar is open */
#menu-toggle:checked ~ .overlay {
opacity: 1;
pointer-events: auto;
}
/* Main content area */
.content {
padding: 80px 20px;
max-width: 800px;
margin: auto;
transition: 0.3s ease;
}
@media (max-width: 600px) {
.sidebar {
width: 250px;
}
}