Divs彼此相邻,与大小,没有破线 [英] Divs next to each other, with size, no linebreak

查看:111
本文介绍了Divs彼此相邻,与大小,没有破线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要许多小的div彼此相邻,没有换行符:

I want many little div-s next to each other, with no linebreak:

<div style="overflow: scroll;">

<div style="float: left; width: 40px;"></div>
<div style="float: left; width: 40px;"></div>
<div style="float: left; width: 40px;"></div>

</div>

问题是,宽度工作,但如果溢出,它会转到新行, 。

the problem is, the width works, but it goes to new line if overflows, so no scroll horizontally.

推荐答案

您可以通过 white-space display:inline-block; 。这样写:

You can achieve this with white-space & display:inline-block;. Write like this:

.parent{
 white-space:nowrap;
overflow:scroll;
}
.parent > div{
 display:inline-block;
 white-space:normal;
}

检查此http://jsfiddle.net/EUtLh/

这篇关于Divs彼此相邻,与大小,没有破线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆