博客列表 >第五节课html标签元素属性作业-2019-9-4 作业

第五节课html标签元素属性作业-2019-9-4 作业

鹰弘网络科技的博客
鹰弘网络科技的博客原创
2019年09月04日 23:45:41647浏览
  1. 实例演示如何消除子元素浮动造成父元素高度折叠的影响

实例

<!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>
        .box {
            width: 200px;
            border: 5px dashed blue;
            overflow: hidden;
        }
        
        .box1 {
            width: 200px;
            height: 200px;
            background: lightgreen;
            float: left;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="box1"></div>
    </div>
</body>

</html>

运行实例 »

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

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

实例

<!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>
        .box {
            width: 1000px;
            margin: 0 auto;
        }
        
        .header {
            width: 100%;
            height: 50px;
            background: lightgrey;
        }
        
        .footer {
            width: 100%;
            height: 50px;
            background: lightgrey;
        }
        
        .main {
            background: lightblue;
            margin: 5px auto;
            position: relative;
        }
        
        .left {
            width: 200px;
            background: lightpink;
            min-height: 800px;
            position: absolute;
            left: 0;
            top: 0;
        }
        
        .right {
            width: 200px;
            background: yellow;
            min-height: 800px;
            position: absolute;
            right: 0;
            top: 0;
        }
        
        .content {
            min-height: 800px;
            background: lightseagreen;
            margin-left: 200px;
            margin-right: 200px;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="header">网页头部</div>
        <div class="main">
            <div class="left">左边</div>
            <div class="content">中间</div>
            <div class="right">右边</div>
        </div>
        <div class="footer">网页尾部</div>
    </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>
        .box {
            width: 1000px;
            margin: 0 auto;
        }
        
        .header {
            width: 100%;
            height: 50px;
            background: lightgrey;
        }
        
        .footer {
            width: 100%;
            height: 50px;
            background: lightgrey;
        }
        
        .main {
            background: lightblue;
            margin: 5px auto;
            position: relative;
            overflow: hidden;
        }
        
        .left {
            background: lightcoral;
            width: 200px;
            min-height: 800px;
            float: left;
        }
        
        .right {
            background: lightseagreen;
            width: 200px;
            min-height: 800px;
            float: right;
        }
        
        .content {
            background: yellow;
            width: 600px;
            min-height: 800px;
            float: left;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="header">网页头部</div>
        <div class="main">
            <div class="left">左边</div>
            <div class="content">中间</div>
            <div class="right">右边</div>
        </div>
        <div class="footer">网页尾部</div>
    </div>
</body>

</html>

运行实例 »

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

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议