美文网首页
实现经典三列布局

实现经典三列布局

作者: duans_ | 来源:发表于2019-03-27 10:10 被阅读0次
20题-经典三列布局-效果图.png

使用定位实现

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>定位实现经典三列布局</title>
    <style>
    *{
        margin: 0;
        padding: 0;
    }
    html,body{
        height: 100%;
    }
    .container{
        position: relative;
        height: 100%;
        text-align: center;
    }
    .left{
        position: absolute;
        left: 0;
        top:0;
        width: 200px;
        height: 100%;
        background-color: red;
    }
    .content{
        background-color: green;
        height: 100%;

    }
    .right{
        position: absolute;
        right:0;
        top:0;
        width: 200px;
        background-color: blue;
        height: 100%;

    }
    </style>
</head>
<body>

<div class="container">
    <!-- 左侧 -->
    <div class="left">
        <h1>左侧导航</h1>
    </div>
    <!-- 中间内容部分 -->
    <div class="content">
        <h1>内容部分</h1>
    </div>
    <!-- 右侧侧边栏 -->
    <div class="right">
        <h1>右侧侧边栏</h1>
    </div>

</div>
    
</body>
</html>

使用浮动实现

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>实现经典三列布局</title>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        #container {
            /* 设置页面最小宽度 */
            min-width: 360px;
            font-size: 30px;
            text-align: center;
        }

        #container div{
            padding: 20px;
        }

        #container .left {
            width: 200px;
            height: 400px;
            float: left;
            background-color: red;
        }

        #container .right {
            width: 200px;
            height: 400px;
            float: right;
            background-color: green;
        }

        #container .middle {
            height: 400px;
            margin: 0 150px 0 200px;
            background-color: blue;
        }
    </style>
</head>

<body>
    <div id="container">
        <div class="left">左侧导航</div>
        <div class="right">右侧侧边栏</div>

        <div class="middle">中间内容部分</div>
    </div>
</body>
</html>

相关文章

网友评论

      本文标题:实现经典三列布局

      本文链接:https://www.haomeiwen.com/subject/rqmavqtx.html