想在DIV中并排放置文本

时间:2013-08-16 02:35:43

标签: html css

enter image description here

我希望在DIV中使用类似的代码实现上述目标:

<div id="container3" style="position: relative;">
    <div id="left" style="position: absolute; padding-left: 10px;">
        About Company<br>Our Team<br>Careers
    </div>
</div>

父DIV的CSS,它将保存所有文本:

#container3 {
    vertical align: top;
    width: 80%;
    height: 150px;
    background-color: #ffffff;
}

2 个答案:

答案 0 :(得分:2)

也许类似于此:

enter image description here

HTML:

<ul class="footer">
    <li class="link">
        Link
    </li>
    <li class="link">
        Link
    </li>
    <li class="link">
        Link
    </li>
    <li class="link">
        Link
    </li>
    <li class="link">
        Link
    </li>
    <li class="link">
        Link
    </li>
    <li class="link">
        Link
    </li>
    <li class="link">
        Link
    </li>
    <li class="link">
        Link
    </li>
    <li class="link">
        Link
    </li>
    <li class="link">
        Link
    </li>
    <li class="link">
        Link
    </li>
</ul>

CSS:

.footer{
    background-color:#000000;
    padding-left:5px;
}

.link{
    color:#ffffff;
    list-style:none;
    display:inline-block;
    width:200px;
    text-align:left;
}

<强> DEMO

Alternate Solutionhttp://jsfiddle.net/xU76e/1/

HTML:

<div class="footer">
    <ul class="footer-links">
        <li class="link">
            Link
        </li>
        <li class="link">
            Link
        </li>
        <li class="link">
            Link
        </li>
        <li class="link">
            Link
        </li>
    </ul>
    <ul class="footer-links">
        <li class="link">
            Link
        </li>
        <li class="link">
            Link
        </li>
        <li class="link">
            Link
        </li>
        <li class="link">
            Link
        </li>
    </ul>
    <ul class="footer-links">
        <li class="link">
            Link
        </li>
        <li class="link">
            Link
        </li>
    </ul>
</div>

CSS:

.footer{
    background-color:#000000;
    overflow:auto;
}

.footer-links{
    padding-left:5px;
    float:left;
    padding:0px 20px;
    list-style:none;
}

.link{
    color:#ffffff;
}

答案 1 :(得分:1)

你可以尝试:

#container3 > div {
float: left;
padding-left: 10px;
/* any additional styling */
}