Created
March 19, 2025 08:00
CSS for a horizontally scrolling section with flexbox and smooth scrolling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Right Column: Enables horizontal scrolling */ | |
.your-right-column-class { | |
overflow-x: auto; /* Enables horizontal scrolling */ | |
white-space: nowrap; /* Prevents content from wrapping */ | |
display: flex; /* Ensures child elements stay in a row */ | |
scroll-behavior: smooth; /* Optional: Smooth scrolling effect */ | |
} | |
/* Optional: Hide scrollbar (WebKit browsers) */ | |
.your-right-column-class::-webkit-scrollbar { | |
display: none; | |
} | |
/* Container: Expands width for smooth scrolling */ | |
.your-container { | |
display: flex; | |
width: 400vw; /* Adjust depending on content */ | |
} | |
/* Ensures each child element takes full viewport width */ | |
.your-container > * { | |
width: 100vw; /* Ensures each item is one viewport width */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment