前端开发笔记前端之美-UI设计

CSS 基础网页布局、圣杯布局、双飞翼布局

2017-12-30  本文已影响91人  sunxiaochuan

概述

image.png
image.png
image.png
image.png

概要

image.png

CSS基础布局

image.png
image.png
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>layout</title>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
        }
        .con{
            width: 980px;
            margin: 0 auto;
        }
        .header{
            height: 150px;
            background-color: orange;
        }
        .footer{
            height: 150px;
            background-color: yellow;
        }
        .content{
            height: 300px;
            background-color: green;
        }
        .content .left{
            height: 300px;
            background-color: aquamarine;
            float: left;
            width: 20%;
        }
        .content .right{
            height: 300px;
            background-color: coral;
            float: right;
            width: 10%;
        }
        .middle{
            height: 300px;
            background-color: red;
        }
        .fx{
            clear: both;
        }
    </style>
</head>
<body>
    <div class="con">
        <div class="header">
            我是header
        </div>
        <div class="content">
            <!-- 如果是中间的内容比较重要的话需要放到前面这样在渲染时先渲染出来  这样的话就需要在 浮动同级的最后面加上一个 div.fx 清除浮动了 -->
            <div class="middle">
                中间
            </div>
            <div class="left">
                左
            </div>
            <div class="right">
                右
            </div>
            
            <div class="fx"></div>
        </div>
        <div class="footer">
            版权信息
        </div>
    </div>
</body>
</html>
image.png
image.png

圣杯布局

image.png
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>layout</title>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
        }
        .con{
            width: 980px;
            margin: 0 auto;
        }
        .header{
            height: 150px;
            background-color: orange;
        }
        .footer{
            height: 150px;
            background-color: yellow;
        }
        .content{
            height: 300px;
            background-color: green;
            padding-left: 100px;
            padding-right: 150px;
        }
        .content .left{
            height: 300px;
            background-color: aquamarine;
            float: left;
            width: 100px;
            margin-left: -100%;
            position: relative;
            left: -100px;
        }
        .content .right{
            height: 300px;
            background-color: coral;
            float: left;
            width: 150px;
            margin-left: -150px;
            position: relative;
            left: 150px;
        }
        .middle{
            height: 300px;
            background-color: red;
            float: left;
            width: 100%;
        }
        .fx{
            clear: both;
        }
    </style>
</head>
<body>
    <div class="con">
        <div class="header">
            我是header
        </div>
        <div class="content">
            <!-- 如果是中间的内容比较重要的话需要放到前面这样在渲染时先渲染出来  这样的话就需要在 浮动同级的最后面加上一个 div.fx 清除浮动了 -->
            <div class="middle">
                中间
            </div>
            <div class="left">
                左
            </div>
            <div class="right">
                右
            </div>
            
            <div class="fx"></div>
        </div>
        <div class="footer">
            版权信息
        </div>
    </div>
</body>
</html>
image.png

双飞翼布局

image.png
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>layout</title>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
        }
        .con{
            width: 980px;
            margin: 0 auto;
        }
        .header{
            height: 150px;
            background-color: orange;
        }
        .footer{
            height: 150px;
            background-color: yellow;
        }
        .content{
            height: 300px;
            background-color: green;
            /*padding-left: 100px;
            padding-right: 150px;*/
        }
        .content .left{
            height: 300px;
            background-color: aquamarine;
            float: left;
            width: 100px;
            margin-left: -100%;
            /*position: relative;
            left: -100px;*/
        }
        .content .right{
            height: 300px;
            background-color: coral;
            float: left;
            width: 150px;
            margin-left: -150px;
            /*position: relative;
            left: 150px;*/
        }
        .middle{
            height: 300px;
            background-color: red;
            float: left;
            width: 100%;
        }
        .middle .inner{
            margin-left: 100px;
            margin-right: 150px;
        }
        .fx{
            clear: both;
        }
    </style>
</head>
<body>
    <div class="con">
        <div class="header">
            我是header
        </div>
        <div class="content">
            <!-- 如果是中间的内容比较重要的话需要放到前面这样在渲染时先渲染出来  这样的话就需要在 浮动同级的最后面加上一个 div.fx 清除浮动了 -->
            <div class="middle">
                <div class="inner">
                    中间
                </div>
            </div>
            <div class="left">
                左
            </div>
            <div class="right">
                右
            </div>
            
            <div class="fx"></div>
        </div>
        <div class="footer">
            版权信息
        </div>
    </div>
</body>
</html>
image.png

扩展

image.png
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>layout</title>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
        }
        .con{
            width: 980px;
            margin: 0 auto;
        }
        .header{
            height: 150px;
            background-color: orange;
        }
        .footer{
            height: 150px;
            background-color: yellow;
        }
        .content{
            height: 300px;
            background-color: green;
            /*padding-left: 100px;
            padding-right: 150px;*/
            overflow: hidden;
        }
        .content .left{
            /*height: 300px;*/
            background-color: aquamarine;
            float: left;
            width: 100px;
            margin-left: -100%;
            /*position: relative;
            left: -100px;*/
            padding-bottom: 9999px;
            margin-bottom: -9999px;
        }
        .content .right{
            /*height: 300px;*/
            background-color: coral;
            float: left;
            width: 150px;
            margin-left: -150px;
            /*position: relative;
            left: 150px;*/
            padding-bottom: 9999px;
            margin-bottom: -9999px;
        }
        .middle{
            /*height: 300px;*/
            background-color: red;
            float: left;
            width: 100%;
        }
        .middle .inner{
            margin-left: 100px;
            margin-right: 150px;
            background-color: blueviolet;
            padding-bottom: 9999px;
            margin-bottom: -9999px;
        }
        .fx{
            clear: both;
        }
    </style>
</head>
<body>
    <div class="con">
        <div class="header">
            我是header
        </div>
        <div class="content">
            <!-- 如果是中间的内容比较重要的话需要放到前面这样在渲染时先渲染出来  这样的话就需要在 浮动同级的最后面加上一个 div.fx 清除浮动了 -->
            <div class="middle">
                <div class="inner">
                    中间
                </div>
            </div>
            <div class="left">
                左
            </div>
            <div class="right">
                右
            </div>
            
            <div class="fx"></div>
        </div>
        <div class="footer">
            版权信息
        </div>
    </div>
</body>
</html>
image.png
上一篇下一篇

猜你喜欢

热点阅读