首页 > 其他 > 详细

布局属性之浮动

时间:2018-06-09 15:16:25      阅读:218      评论:0      收藏:0      [点我收藏+]

编辑本博客

技术分享图片
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>布局属性浮动</title>
    <style type="text/css">
        *{
            padding:0;
            margin:0;
        }
        .box1{
            width:50px;
            height:50px;
            background-color:red;
            float:left;
        }
        .box2{
            width:50px;
            height:50px;
            background-color:green;
            float: right;
        }
    </style>
</head>
<body>
    <div class="box1">

    </div>
<div class="box2"></div>
</body>
</html>
View Code

块级元素到一行显示,并且都可设置宽和高

技术分享图片

脱标

即脱离标准文档流

技术分享图片
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>浮动脱标</title>
    <style type="text/css">
        .box1{
            width:80px;
            height:80px;
            background-color:red;
            float: left;
        }
        .box2{
            width:100px;
            height:100px;
            background-color:yellow;
        }
    </style>
</head>
<body>
    <div class="box1">小红</div>
    <div class="box2">小黄</div>
</body>
</html>
View Code

小红设置了浮动,脱离了文档标准流,这时小黄就是第一个元素,所以渲染到了最上面

技术分享图片

相互贴靠

有字围效果

紧凑效果

布局属性之浮动

原文:https://www.cnblogs.com/yaya625202/p/9159488.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!