我正在尝试创建一个div,而不是将图像移动到下一行,而是继续溢出浏览器宽度。
HTML标记:
<div class="carousel">
<img src="http://placehold.it/200x200"/>
<img src="http://placehold.it/200x200"/>
<img src="http://placehold.it/200x200"/>
<img src="http://placehold.it/200x200"/>
<img src="http://placehold.it/200x200"/>
<img src="http://placehold.it/200x200"/>
<img src="http://placehold.it/200x200"/>
<img src="http://placehold.it/200x200"/>
<img src="http://placehold.it/200x200"/>
<img src="http://placehold.it/200x200"/>
</div>
CSS:
.carousel {
overflow: scroll;
overflow-x: hidden;
}
.carousel img{
display: inline-block;
}
无论如何,没有为div设置宽度就可以做到这一点吗?
添加white-space:nowrap
到您的.carousel
div中:
.carousel {
overflow: scroll;
overflow-x: hidden;
white-space:nowrap;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句