Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
997 views
in Technique[技术] by (71.8m points)

html - Flexbox displays divs incorrectly rather than making the container scrollable

I was playing with flexbox and, when I attempted to make a scrollable list of days, I noticed that the first two days of the "week" are being "swallowed". The container is scrollable, but the beginning of the list doesn't display.

Basic code:

<div class="p-1 p-sm-3">
    <div class="d-flex justify-content-center text-center" style="overflow-x: auto;">
        <div class="px-4 py-5 mx-1 bg-white rounded">
            <h3>04</h3>
            <p>04/01/2020</p>
        </div>

        ...other days of the week here
    </div>
</div>

Full Fiddle: https://jsfiddle.net/98vf7xek/

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your problem is caused by rule justify-content: center!important, which is generated by class justify-content-center. Here:

<div class="d-flex justify-content-center text-center" style="overflow-x: auto;">
...
</div>

Just remove this class and your problem will be solved.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...