[英]How to center a Scroll element with Overflow
I am working on a design that I had to center some images.我正在设计一个必须将一些图像居中的设计。 I have tried UI Slider and Slick Slider to get it working, but they always break in Material CSS Modal.我已经尝试过 UI Slider 和 Slick Slider 来让它工作,但它们总是在 Material CSS Modal 中中断。
Here is the screenshot of what I am trying to achieve.这是我想要实现的屏幕截图。
I tried to use this CSS我尝试使用这个 CSS
//HTML //HTML
<div class="scroolable">
<img src="/assets/card4.png" alt="">
<img src="/assets/card4.png" alt="">
<img src="/assets/card4.png" alt="">
<img src="/assets/card4.png" alt="">
<img src="/assets/card4.png" alt="">
</div>
//css //css
.scroolable {
display: flex;
justify-content: center;
overflow: scroll;
}
justify-content: center;对齐内容:居中; doesn't seems to work似乎不起作用
您需要在此处使用align-items
( https://developer.mozilla.org/fr/docs/Web/CSS/align-items ) 而不是justify-content
。
As Jeyffrey has stated above align-items
is the thing you're looking for.正如Jeyffrey在上面所说的align-items
是你正在寻找的东西。 You might want to take a look at https://css-tricks.com/snippets/css/a-guide-to-flexbox/ as it might be helpful.您可能想看看https://css-tricks.com/snippets/css/a-guide-to-flexbox/,因为它可能会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.