如何使用 CSS 并排浮动 3 个 div? [英] How to float 3 divs side by side using CSS?
本文介绍了如何使用 CSS 并排浮动 3 个 div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如何让 2 个 div 并排浮动,只需将一个向左浮动,另一个向右浮动.
但是如何用 3 个 div 来做到这一点,或者我应该为此目的使用表格?
解决方案
只要给他们一个宽度和float: left;
,这是一个例子:
<div style="float: left; width: 200px;">Left Stuff</div><div style="float: left; width: 100px;">Middle Stuff</div><div style="float: left; width: 200px;">Right Stuff</div><br style="clear: left;"/>
I know how to make 2 divs float side by side, simply float one to the left and the other to the right.
But how to do this with 3 divs or should I just use tables for this purpose?
解决方案
Just give them a width and float: left;
, here's an example:
<div style="width: 500px;">
<div style="float: left; width: 200px;">Left Stuff</div>
<div style="float: left; width: 100px;">Middle Stuff</div>
<div style="float: left; width: 200px;">Right Stuff</div>
<br style="clear: left;" />
</div>
这篇关于如何使用 CSS 并排浮动 3 个 div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文