如何将div并排放置(How to place div side by side)

编程入门 行业动态 更新时间:2024-10-08 22:54:31
如何将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.

更多推荐

本文发布于:2023-08-04 18:53:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1419221.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   div   side   place

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!