右对齐div

时间:2013-04-07 19:54:40

标签: css html alignment

我正在尝试将div对齐,但它只显示在底部。

Issue

CSS:

.homeWrapper{
    padding: 12px;
    width:auto;
}
.content_inner{
    height: auto;
    background-color: #6c93b8;
    margin:12px;
    -moz-border-radius:5px;
    -webkit-border-radius:5px;
    border-radius:5px;
    clear:both;
}
.leftCol{
    display: inline-block;
    width:448px;
    background-color: red;
}
.rightCol{
    display: inline-block;
    width:430px;
    background-color: green;
    clear:both;
}

HTML:

    <div class="homeWrapper">
            <div class="content_inner">
                <h1><span class="color_red">Contact</span> Agrilife</h1>
                    <div class="leftCol">
                        {{ template:body }}
                    </div>
                    <div class="rightCol">
                        text
                        text
                        text

                    </div>  
        </div>
    </div>  

2 个答案:

答案 0 :(得分:1)

尝试使用float

.leftCol{
    float:left;
    width:448px;
    background-color: red;
}
.rightCol{
    float:right;
    width:430px;
    background-color: green;
    clear:both;
}

答案 1 :(得分:0)

float:right;.rightCol

一起使用