JSFiddle - React, Tailwind, and code Playground
by g4165262
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Selectable Tiles (No JavaScript)</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style>
/* Container for all tiles */
.tile-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
margin-top: 20px;
}
/* Individual tile styling */
.tile {
padding: 20px;
background-color: #f8f9fa;
border-radius: 8px;
text-align: center;
transition: transform 0.3s, background-color 0.3s;
cursor: pointer;
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
}
/* Hover effect */
.tile:hover {
transform: translateY(-5px);
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
}
/* Icon styling */
.tile i {
font-size: 40px;
color: #007bff;
}
/* Title styling */
.tile h5 {
margin-top: 15px;
font-size: 1.25rem;
}
/* Description styling */
.tile p {
font-size: 0.9rem;
color: #6c757d;
margin-bottom: 0;
}
/* Selected state styling using CSS pseudo-classes */
input[type="radio"] {
display: none; /* Hide radio buttons */
}
label {
display: block;
cursor: pointer;
}
input[type="radio"]:checked + label .tile {
background-color: #007bff;
color: white;
...