Blogger Information
Blog 16
fans 1
comment 0
visits 14233
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
2019年7月5日作业(三) - 浮动的实现原理与清除的技巧
杜强_上海_315106编程学习
Original
902 people have browsed it

以下代码为浮动的实现原理与清除的技巧

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="static/css/style4.css">
    <title>浮动float</title>
</head>
<body>
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
<div class="box4"></div>
</body>
</html>
.box1 {
    width: 150px;
    height: 150px;
    background-color: red;
}
.box2 {
    width: 200px;
    height: 200px;
    background-color: blue;
}
.box1 {
    float: left;
}

.box2 {
    float: left;
}
.box3 {
    width: 300px;
    height: 300px;
    background-color: green;
}
.box3 {
    float: right;
}

.box4 {
    width: 100%;
    height: 300px;
    background-color: black;
}
.box4 {
    clear: left;
    clear: right;
}

以上代码执行结果截图:

0705-3.png

总结:浮动的实现原理与清除的技巧后应助以下几点:

  1. float为浮动

  2. clear为不受浮动影响

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