I want the container with the "overflow
" class to be able to have horizontal scroll
since it is wider than its direct parent. how can I do it?
html, body{
padding:0px;
margin:0px;
}
.container{
display:flex;
background:yellow;
width:100%;
height:100px;
max-width:100%;
}
.container div{
border:1px solid red;
}
.sizeSmall{
width:200px;
}
.overflow{
width:4000px;
overflow:auto;
}
<div class="container">
<div class="sizeSmall"></div>
<div class="overflow"></div>
<div>
2
Answers
You would probably need an inner container inside the one you want to scroll:
Add
overflow-x: scroll;
to.container
and useflex-shrink: 0;
on the flex children.You can also accomplish this without
flex-shrink
usingmin-width
on theflex
children.