I have a web page that sequentially adds various sizes of fixed width panels (flex: none) from left to right as the user drills down. When the panels reach (or will overreach) the end of the page I want the first panel (and subsequent panels) to 'scroll' to the left (overflow hidden is acceptable, partial content visible is ok)
Originally aligned left as follows when panel ONE then TWO, etc is added
=============================================================
= =
= ----------- ----------- ----------- ----------- =
= | | | | | | | | =
= | ONE | | TWO | | THREE | | FOUR | =
= | | | | | | | | =
= ----------- ----------- ----------- ----------- =
= =
==============================================================
Then when FIVE is added it will overreach the end of the page so panel ONE is scrolled out of view (overflow hidden is ok)
=============================================================
= =
=-- ----------- ----------- ----------- ----------- =
= | | | | | | | | | =
= | | TWO | | THREE | | FOUR | | FIVE | =
= | | | | | | | | | =
=-- ----------- ----------- ----------- ----------- =
= =
=============================================================
Conversely, when panel FIVE (or any other) is removed, then ONE should go back into view.
So far I have this:
<div class="container-fluid">
<div class="panel-container">
<div class="panel">
1 of 4
</div>
<div class="panel">
2 of 4
</div>
<div class="panel">
3 of 4
</div>
</div>
</div>
.panel-container {
justify-content: flex-end;
margin-top: 1rem;
width: 100%;
display: flex;
width: fit-content;
}
.panel {
border: solid 1px #6c757d;
padding: 10px;
flex: none;
width:300px;
}
I've also tried this:
.panel-container {
margin-top: 1rem;
justify-content: flex-end;
width: auto;
right: inherit;
display: inline-flex;
}
My css only works when I don't set the width of the last panel, but then the width expands to fit the remaining space which is not what I want. Prefer a css solution using flex box, but if that's not possible then anything workable would be appreciated
any help would be appreciated!