内联div元素 [英] Inline div elements

查看:145
本文介绍了内联div元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把div元素放在一起。问题是,即使两个元素在同一行上有足够的空间,新的div会移动到下一行,如果没有足够的空间,我只需要另一个div就可以进入下一行。



有人知道怎么做吗? CSS显示样式为 display:inline-block;



这允许元素保持块状功能,同时也允许它内联显示。这是一个介于两者之间的中间房屋。

(但请注意,旧版IE的兼容性问题)


I'm trying to put div elements right next to each other. The problem is, even if there is enough room for the two elements to be on the same line, the new div moves itself to the next line, I need the other div only to go to the next line if there isn't enough room.

Does anybody know how to do this?

解决方案

Set the CSS display style to display:inline-block;.

This allows the element to keep it's block-like functionality, while also allowing it to be displayed inline. It's a half-way house between the two.

(But note that there are some compatibility issues with older versions of IE)

这篇关于内联div元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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