如何将div并排放置(How to place div side by side)
我有一个主要的包装div设置为100%的宽度。 在里面我想要两个div,一个是固定的宽度,另一个填充其余的空间。 我如何浮动第二个div来填补其余的空间。 感谢任何帮助。
I have a main wrapper div that is set 100% width. Inside that i would like to have two divs, one that is fixed width and the other that fills the rest of the space. How do i float the second div to fill the rest of the space. Thanks for any help.
最满意答案
有很多方法可以做你所要求的:
使用CSS float属性 :
<div style="width: 100%; overflow: hidden;"> <div style="width: 600px; float: left;"> Left </div> <div style="margin-left: 620px;"> Right </div> </div>使用CSS display属性 - 可以用来使div的行为像一个table :
<div style="width: 100%; display: table;"> <div style="display: table-row"> <div style="width: 600px; display: table-cell;"> Left </div> <div style="display: table-cell;"> Right </div> </div> </div>有更多的方法,但这两个是最受欢迎的。
There are many ways to do what you're asking for:
Using CSS float property:
<div style="width: 100%; overflow: hidden;"> <div style="width: 600px; float: left;"> Left </div> <div style="margin-left: 620px;"> Right </div> </div>Using CSS display property - which can be used to make divs act like a table:
<div style="width: 100%; display: table;"> <div style="display: table-row"> <div style="width: 600px; display: table-cell;"> Left </div> <div style="display: table-cell;"> Right </div> </div> </div>There are more methods, but those two are the most popular.
更多推荐
发布评论