div并排放置 [英] divs side by side with space between
本文介绍了div并排放置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么两个div并排且它们之间只有很小的间距如此困难?
Why is it so difficult to have two divs side by side with little space between them?
我尝试过
<div style="height: 160px; width: 100%; box-sizing:border-box; display:table;">
<div class="introwrapper" style="height:100%; width:25%;display:table-cell;background: pink;box-sizing: border-box;">First Div</div>
<div style="width:5%;">
</div>
<div class="introwrapper" style="height:100%; width:25%;display:table-cell; background: blue; box-sizing: border-box;">second div</div>
</div>
但是我之间没有空格.它遍及SO和其他博客,但没有合适的解决方案.
But I cannot get a space between. Its been all over SO and other blogs but none has right solution.
推荐答案
您可能需要使用 float:left
并排对齐两个DIV
You may need to use float:left
to align two DIVs side by side
<div style="height: 160px; width: 100%; box-sizing:border-box; display:table;">
<div class="introwrapper" style="float:left;margin-right:30px; height:100%; width:25%;display:table-cell;background: pink;box-sizing: border-box;">First Div</div>
<div class="introwrapper" style="float:left;height:100%; width:25%;display:table-cell; background: blue; box-sizing: border-box;">second div</div>
<br style="clear:left" />
</div>
这篇关于div并排放置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文