如何使两个div水平排列? [英] How to make two div horizontally arranged?
本文介绍了如何使两个div水平排列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么div2在最左边的第二行没有?
我的代码是:
Why did the ''div2'' no in the second row of the left-most?
My code is:
<div>
<div style="width: 100px; height: 100px; float: left">div1</div>
<label>div1label</label>
</div>
<div>
<div style="width: 100px; height: 100px; float: left">div2</div>
<label>div2label</label>
</div>
现在的效果是:
div1 div1label
(空白..)div2 div2label
但我想要的效果是:
div1 div1label
div2 div2label
Now the effect is:
div1 div1label
(blank..)div2 div2label
But I want the effect is:
div1 div1label
div2 div2label
推荐答案
您好,
请在下面获取战利品sample
Hello,
Please have a loot at following sample
<!DOCTYPE html>
<html>
<body>
<div>
<div style="width: 100px; height: 100px; float: left">div1</div>
<label style="float:left;">div1label</label>
</div>
<div>
<div style="width: 100px; height: 100px; float: left;clear:left;">div2</div>
<label style="float:left;">div2label</label>
</div>
</body>
</html>
下面的那个没有浮动。
The one below is without float.
<!DOCTYPE html>
<html>
<body>
<div>
<div style="width: 100px; height: 100px; display:inline-block;">div1</div>
<label>div1label</label>
</div>
<div>
<div style="width: 100px; height: 100px;display:inline-block;">div2</div>
<label>div2label</label>
</div>
</body>
</html>
问候,
Regards,
也试试这个
also try this
<div>
<div style="overflow-y:scroll;display: inline-block; writing-mode:lr-tb; word-wrap:break-word;white-space:normal;">div1</div>
<label>div1label</label>
</div>
<div>
<div style="overflow-y:scroll;display: inline-block; writing-mode:lr-tb; word-wrap:break-word;white-space:normal;">div2</div>
<label>div2label</label>
</div>
>
如果没有必要,你可以避免嵌套,并将其position属性设置为绝对值,
通过顶部和左边给它坐标:
If not necessary you can avoid nesting and make its position property set to absolute and
give it co-ordinates through top and left:
<div style="position:absolute;top:500px; left:100px">Hello</div>
<div style="position:absolute;top:500px; left:200px">World</div>
这将获得内联的两个除法元素。
This will get the two division elements inline.
这篇关于如何使两个div水平排列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文