水平对齐3个div

时间:2013-11-01 11:27:28

标签: 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;}

1 个答案:

答案 0 :(得分:1)

每个子框都需要.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>