Category menu scroll
by pphheerroonn
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Apple Product Categories</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
margin: 0;
padding: 0;
}
/* Container for the entire component */
.scroll-menu-container {
position: relative;
max-width: 1200px;
margin: 20px auto;
padding: 0 15px;
}
/* Styles for the scrollable container */
.container {
overflow-x: auto;
white-space: nowrap;
padding: 20px 0;
scroll-behavior: smooth;
-ms-overflow-style: none; /* Hide scrollbar for IE and Edge */
scrollbar-width: none; /* Hide scrollbar for Firefox */
cursor: grab; /* Show grab cursor to indicate draggable */
user-select: none; /* Prevent text selection during drag */
}
/* When actively grabbing the scroll container */
.container.grabbing {
cursor: grabbing;
}
/* Hide scrollbar for Chrome, Safari and Opera */
.container::-webkit-scrollbar {
display: none;
}
/* Styles for each tile */
.tile {
display: inline-block;
width: 200px;
margin-right: 20px;
border-radius: 12px;
overflow: hidden;
box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.08);
background-color: #ffffff;
transition: transform 0.3s ease, box-shadow 0.3s ease;
vertical-align: top; /* Align tiles at the top */
}
.tile:hover {
transform: translateY(-5px);
box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
}
/* Disable hover effect during dragging */
.grabbing .tile:hover {
transform: none;
}
/* Styles for the image */
.tile img {
width: 100%;
height: 140px;
object-fit: contain;
...