Skip to content

Instantly share code, notes, and snippets.

@fastfingertips
Created December 18, 2024 11:41
Show Gist options
  • Save fastfingertips/03a63f66c2b7bf7ce33c2a56298fb64d to your computer and use it in GitHub Desktop.
Save fastfingertips/03a63f66c2b7bf7ce33c2a56298fb64d to your computer and use it in GitHub Desktop.
Dynamic responsive grid with interactive cards, generated using HTML and CSS.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Grid</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: 'Segoe UI', sans-serif;
color: white;
background: #0d0d14;
padding: min(50px, 7%);
text-align: center;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 20px;
max-width: 1200px;
margin: 30px auto;
}
.card {
padding: 1.5em;
border: 1px solid #4b525c;
border-radius: 10px;
background: #222;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: transform 0.3s, box-shadow 0.3s;
}
.card:hover {
transform: translateY(-5px);
box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body>
<div class="grid" id="grid"></div>
<script>
const grid = document.getElementById("grid");
Array.from({ length: 15 }).forEach(() => {
const card = document.createElement("div");
card.className = "card";
card.innerHTML = `
<h2>Title</h2>
<p>Sample text for the card.</p>`;
grid.appendChild(card);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment