html - 将图像放在滑块内的两行中
问题描述
我正在尝试创建一个手动滑块,其中图像应该在两行 - 水平滑动。我试图用 flexbox 来做,但是我做错了...欢迎所有建议
.slider {
display: flex;
justify-content: stretch;
flex-wrap: wrap;
overflow-x: scroll;
height: 230px;
width: 400px;
height: 200px;
}
img {
width: 120px;
height: 100px;
object-fit: cover;
}
<div class="slider">
<img src="http://placekitten.com/500/300" alt="">
<img src="http://placekitten.com/200/300" alt="">
<img src="http://placekitten.com/700/300" alt="">
<img src="http://placekitten.com/100/300" alt="">
<img src="http://placekitten.com/700/300" alt="">
<img src="http://placekitten.com/500/300" alt="">
<img src="http://placekitten.com/500/300" alt="">
<img src="http://placekitten.com/500/300" alt="">
<img src="http://placekitten.com/500/300" alt="">
</div>
解决方案
尝试这个:
.slider {
display: flex;
flex-wrap: wrap;
overflow-x: scroll;
width: 400px;
height: 200px;
}
img {
width: 50%;
height: 100%;
object-fit: cover;
}
推荐阅读
- python - 无法从我的 Django 视图中加载第二个 Highcharts 图表
- java - 如何使用 jetty 和 spring boot 收集和获取连接池统计信息?
- javascript - 在tinymce编辑器中模糊时如何获取父iFrame ID?
- android - 为什么android webview没有从缓存中加载所有资源?
- vba - 我想使用 vba 将光标移动到 word 中的特定表格下方
- r - 加速函数
- mysql - 将所有正值求和为 col1,将所有负值求和为 col2,并按名称分组 SQL
- regex - 如何在正则表达式中删除某些字符和连字符后的所有内容?
- generics - 为特征实现 std::ops::Add
- c++ - 下面的代码有什么问题。我收到运行时错误