如何并排放置div [英] How to place div side by side

查看:166
本文介绍了如何并排放置div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主要的包装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.

推荐答案

有很多方法可以满足您的要求:

There are many ways to do what you're asking for:


  1. 使用 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 s像

    <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.

    这篇关于如何并排放置div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆