css - 水平对齐 3 个 div

标签 css html alignment

我有 3 个要水平对齐的 div,我已将此代码用于我网站上的其他 div,它们正在运行,这些代码中是否缺少某些内容? example

#christmas_product_boxes{width:1000px; height:auto;}
.christmas_boxes {float:left; width:300px; height:auto;}
.christmas_boxes + .christmas_boxes {margin-left:20px;}
.christmas_boxes > div {width:300px; height:auto; clear:both;}
.christmas_mattress_title {color:#000000;}
.christmas_pillows_title {color:#2B436B;}
.christmas_beds_title {color:#333333;}
.christmas_mattress_text {font-size:13px;}
.christmas_pillows_text {font-size:12px;}
.christmas_beds_text {font-size:11px;}

最佳答案

每个子框都需要有 .christmas_boxes 类,如下所示:

<div id="christmas_product_boxes">
    <div class="christmas_boxes">
        <div class="christmas_mattress">
        ...
    </div>
    <div class="christmas_boxes">
        <div class="christmas_pillows">
        ...
    </div>
    <div class="christmas_boxes">
        <div class="christmas_beds">
        ...
    </div>
</div>

关于css - 水平对齐 3 个 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19725853/

相关文章:

html - 三列内联 block 内容

javascript - 带有自定义滚动条的 jQuery 选择框 (roblaplaca) 不起作用

html - iframe 与父 <p> 对齐

gcc - c 指针对齐

html - 在输入下方显示验证消息(IE9 和 IE7)

html - 有长缓存过期 : need to rename background img files as well as css?

jquery - 下拉菜单闪烁,Firefox 除外

html - margin : 0 auto; not centering because there are divs to the left and right

css - <dl> 不允许显示 :inline-block like <div> allows for

javascript - 如何在单击按钮时以模式读取页面的当前 url?