I've been working on developing a carousel similar to Netflix, but I'm facing an issue with responsiveness. I've been using a codepen example as a reference:
The problem lies in the hardcoded width and height used in the example. I'd prefer to make it responsive by utilizing percentages for measurements. My initial thought was to use the viewport width units (vw
), however, this approach didn't solve the issue as it doesn't take into account the scrollbar. This leads to each carousel item being wider than intended when set to 20vw (aiming for 20% of viewport size) due to the inclusion of the scrollbar.
Any suggestions on how I can resolve this issue?