具有相同高度分隔符的流体布局页脚

时间:2013-04-29 21:16:32

标签: html css fluid-layout

我正在开发流畅布局网页的页脚。这是html:

<div id="footer">
    <div id="lists">
        <div class="list1" id="list-sep">
            <p id="footer-par">
                Lorem Ipsum<br />
                Lorem Ipsum<br />
                Lorem Ipsum Lorem Ipsum<br />
                Lorem Ipsum<br />
                Lorem Ipsum Lorem Ipsum<br />
                PEC<br />
                Lorem Ipsum<br />
                <br />
                &copy; region<br />
            <p>
        </div>
        <div class="list1" id="list-sep">
            <ul>
                <li class="footer-point">President</li>
                <li class="footer-point">Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum Lorem Ipsu</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum</li>

            </ul>
        </div>
        <div class="list1" id="list-sep">
            <ul>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum</li>
            </ul>
        </div>
        <div class="list1">
            <ul>
                <li class="footer-point">Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum </li>
                <li class="footer-point">Lorem Ipsum </li>
            </ul>
        </div>
        <hr />
</div>

这是CSS:

@charset "UTF-8";
/* CSS Document */

* {
    margin:0;
    padding:0;
}

#footer {


    height:auto;
    width:100%;
    float:left;
    margin-top:40px;


}

#lists {

    width:75%;

    height:auto;
    margin:20px auto 0 auto;



}



.list1 {


    float:left;
    width:20%;
    height:100%;
    min-height:116px;
    display:block;
    padding-left:4%;
    /*padding-bottom:44px;*/
    /*padding-top:21px;*/


}


#list-sep {

    border-right:1px solid #CCCCCC;


}

.footer-point {

    display:block;
    margin-top:5px;
    font-family:'Myriad Pro';
    font-size:0.6em;
    color:#CCC;
}

#footer-par {

    margin-top:20%;
    margin-bottom:20%;
    font-family:'Myriad Pro';
    font-size:0.6em;
    color:#CCC;

    height:100%;

}

ul {


    margin-top:20%; 
    margin-bottom:20%;

}

列的高度和宽度必须适应其中的文本量(调整浏览器窗口大小时),但三个分隔符必须具有相同的高度。此外,在调整浏览器大小时,我希望三个分隔符根据文本量调整其高度,但它们必须具有相同的高度。换句话说,分隔符必须适应具有大多数文本的列。有人可以帮帮我吗?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

CSS display: table就是你想要的。 E.g。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">

<style media="all">
@charset "UTF-8";
/* CSS Document */

* {
    margin:0;
    padding:0;
}

#footer {
    height:auto;
    width:100%;
    float:left;
    margin-top:40px;
}

#lists {
    display: table;
    width:75%;
    height:auto;
    margin:20px auto 0 auto;
    border-bottom: 1px solid #ccc;
}

.list1 {
    display: table-cell;
    width:20%;
    padding:4%;
}


#list-sep {
    border-right:1px solid #CCCCCC;
}

.footer-point {
    display:block;
    margin-top:5px;
    font-family:'Myriad Pro';
    font-size:0.6em;
    color:#CCC;
}

#footer-par {
    margin-top:20%;
    margin-bottom:20%;
    font-family:'Myriad Pro';
    font-size:0.6em;
    color:#CCC;
    height:100%;
}

ul {
    margin-top:20%; 
    margin-bottom:20%;
}
</style>

</head>
<body>

<div id="footer">
    <div id="lists">
        <div class="list1" id="list-sep">
            <p id="footer-par">
                Lorem Ipsum<br />
                Lorem Ipsum<br />
                Lorem Ipsum Lorem Ipsum<br />
                Lorem Ipsum<br />
                Lorem Ipsum Lorem Ipsum<br />
                PEC<br />
                Lorem Ipsum<br />
                <br />
                &copy; region<br />
            <p>
        </div>
        <div class="list1" id="list-sep">
            <ul>
                <li class="footer-point">President</li>
                <li class="footer-point">Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum Lorem Ipsu</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum</li>

            </ul>
        </div>
        <div class="list1" id="list-sep">
            <ul>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum</li>
            </ul>
        </div>
        <div class="list1">
            <ul>
                <li class="footer-point">Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum</li>
                <li class="footer-point">Lorem Ipsum </li>
                <li class="footer-point">Lorem Ipsum </li>
            </ul>
        </div>
</div>

</body>
</html>