Blogger Information
Blog 9
fans 0
comment 0
visits 6162
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
CSS布局原理与实现
橙汁的博客
Original
559 people have browsed it
  1. 实例演示如何消除子元素浮动造成父元素高度折叠的影响

    clipboard.png

    实例

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <style>
            #div1 {
                width: 300px;
                border: 4px dashed #f90;
                /* display: inline-block; */
                overflow: hidden;
            }
            
            #div2 {
                width: 300px;
                height: 400px;
                background-color: aqua;
                float: left;
            }
        </style>
    </head>
    
    <body>
        <div id="div1">
            <div id="div2"></div>
        </div>
    </body>
    
    </html>

    运行实例 »

    点击 "运行实例" 按钮查看在线实例

    2. 实例演示三列布局的实现原理( 绝对定位实现, 浮动定位实现)

    4632.jpg

    实例绝对定位

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>三列布局-绝对定位</title>
        <style>
            .header,
            .footer {
                width: 1000px;
                height: 50px;
                background-color: aliceblue;
                margin: 0 auto;
            }
            
            .main {
                width: 1000px;
                background-color: aquamarine;
                margin: 10px auto;
                
                position: relative;
            }
            .left{
                width:200px;
                min-height: 800px;
                background-color: bisque;
    
                position: absolute;
                left:0;
                top:0;
            }
            .content{
                min-height: 800px;
                background-color:lawngreen;
    
                margin: 0 200px;
            }
            .right{
                width:200px;
                min-height: 800px;
                background-color:lightcoral;
    
                position: absolute;
                right:0;
                top:0;
            }
        </style>
    </head>
    
    <body>
        <div class="header">header</div>
        <div class="main">
            <div class="left">left</div>
            <div class="content">content</div>
            <div class="right">right</div>
        </div>
        <div class="footer">footer</div>
    </body>
    
    </html>

    运行实例 »

    点击 "运行实例" 按钮查看在线实例

实例浮动定位

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>三列布局-浮动定位</title>
    <style>
        .header,
        .footer {
            width: 1000px;
            height: 50px;
            background-color: aliceblue;
            margin: 0 auto;
        }
        
        .main {
            width: 1000px;
            background-color: aquamarine;
            margin: 10px auto;
            overflow: hidden;
        }
        
        .left {
            width: 200px;
            min-height: 800px;
            background-color: bisque;
            float: left;
        }
        
        .content {
            width: 600px;
            min-height: 800px;
            background-color: lawngreen;
            float: left;
        }
        
        .right {
            width: 200px;
            min-height: 800px;
            background-color: lightcoral;
            float: right;
        }
    </style>
</head>

<body>
    <div class="header">header</div>
    <div class="main">
        <div class="left">left</div>
        <div class="content">content</div>
        <div class="right">right</div>
    </div>
    <div class="footer">footer</div>
</body>

</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:qualified

Teacher's comments:三列布局是一切布局的集大成者
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post