Note: NOT a duplicate of : Flexbox displays divs incorrectly rather than making the container scrollable Can't scroll to top of flex item that is overflowing container
My use-case attempts to center the overflowing items. Solutions acknowledge this limitation, without solving it. (Their items are not centered)
Imagine if Netflix presented their choices with the middle item positioned in the center of the screen. That's the effect I'm going for with my columns sroller, but my first item is partially cut off. I found a solution on SO using jQuery, but I'd rather wrestle CSS into submission. Need to tag one of you in though... got any ideas?
* {
font-family: sans-serif;
}
.options-wrapper {
font-size: 3vw;
text-align: center;
}
.options-wrapper .options-visualized {
display: flex;
flex-wrap: nowrap;
overflow-x: scroll;
justify-content: center;
margin: 0 auto;
}
.options-wrapper .options-visualized .option {
flex-basis: 40vw;
flex-shrink: 0;
margin: 0 8vw;
display: flex;
flex-direction: column;
}
.options-wrapper .options-visualized .option:first-of-type {
margin-left: 2vw;
}
.options-wrapper .options-visualized .option:last-of-type {
margin-right: 2vw;
}
.options-wrapper .options-visualized .option img {
width: 100%;
margin: 0 auto;
}
.options-wrapper .options-visualized .option .option-label {
margin-top: 1em;
flex-basis: 100%;
font-size: 0.92em;
line-height: 1.25;
}
.options-wrapper .options-visualized .option .option-label span {
display: block;
}
<div class="options-wrapper graded-bg">
<h6 class="options-title">options:</h6>
<div class="options-visualized">
<div class="option">
<img src="https://cdn.pixabay.com/photo/2020/03/19/23/32/willow-catkin-4949064_960_720.jpg">
<div class="option-label"><span class="name">Option 1</span></div>
</div>
<div class="option">
<img src="https://cdn.pixabay.com/photo/2020/03/19/23/32/willow-catkin-4949064_960_720.jpg">
<div class="option-label"><span class="name">Option 2</span></div>
</div>
<div class="option">
<img src="https://cdn.pixabay.com/photo/2020/03/19/23/32/willow-catkin-4949064_960_720.jpg">
<div class="option-label"><span class="name">Option 3</span></div>
</div>
</div>
</div>
Here's a pen: https://codepen.io/sashaikevich/pen/yLgbWQx