如何水平对齐两个div [英] How to Align Two Divs Horizontally

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

问题描述

我需要将2个div彼此相邻,这样每个都包含一个标题和一个项目列表,类似于

I need to align 2 divs next to each other, so that each contains a title and a list of items, similar to

<div>
    <span>source list</span>
    <select size="10">
        <option />
        <option />
        <option />
    </select>
</div>

<div>
    <span>destination list</span>
    <select size="10">
        <option />
        <option />
        <option />
    </select>
</div>

任何人都可以建议如何解决这个问题?这是非常容易做表,但我不想使用表!

Can anyone suggest how to solve this problem? It's remarkably easy to do with tables, but I don't want to use tables!

感谢

Dave

推荐答案

在父容器中浮动div。

Float the divs in a parent container.

<div class="aParent">
    <div>
        <span>source list</span>
        <select size="10">
            <option />
            <option />
            <option />
        </select>
    </div>

    <div>
        <span>destination list</span>
        <select size="10">
            <option />
            <option />
            <option />
        </select>
    </div>
</div>

,样式如下:

.aParent div {
  float: left;
  clear: none; 
}

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

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