码迷,mamicode.com
首页 > Web开发 > 详细

CSS float

时间:2017-03-27 15:47:09      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:快速   style   display   code   演示   img   pre   att   nbsp   

pytharm中快速写4个div    : div.div1*4 Tab

演示代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>FloatTest</title>
    <style>
               .div1{
                   text-align: center;
                   line-height: 50px;
                   width: 30px;
                   height: 50px;
                   background-color: #2aabd2;
                   float: left;
        }
                .div2{
                    text-align: center;
                    line-height: 50px;
                    width: 40px;
                    height:50px;
                    background-color: #8a6d3b;
                    float: left;

        }
                .div3{
                    text-align: center;
                    line-height: 50px;
                    width: 50px;
                    height:60px;
                    background-color: #b92c28;
                  

        }
                .div4{
                    text-align: center;
                    line-height: 50px;
                    width: 100px;
                    height:70px;
                    background-color: #e90592;

                }
    </style>
</head>
<body>
<div class="div1">1</div>
<div class="div2">2</div>
<div class="div3">3</div>
<div class="div4">4</div>
</body>
</html>

技术分享

 

给div1跟div2添加float:left

技术分享

给div3,div4添加float: left;并且让3 4在第二行,需要给3清楚浮动 clear: both;

技术分享
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>FloatTest</title>
    <style>
               .div1{
                   text-align: center;
                   line-height: 50px;
                   width: 30px;
                   height: 50px;
                   background-color: #2aabd2;
                   float: left;
        }
                .div2{
                    text-align: center;
                    line-height: 50px;
                    width: 40px;
                    height:50px;
                    background-color: #8a6d3b;
                    float: left;


        }
                .div3{
                    text-align: center;
                    line-height: 50px;
                    width: 50px;
                    height:60px;
                    background-color: #b92c28;
                    float: left;
                    clear: both;


        }
                .div4{
                    text-align: center;
                    line-height: 50px;
                    width: 100px;
                    height:70px;
                    background-color: #e90592;
                    float: left;

                }
    </style>
</head>
<body>
<div class="div1">1</div>
<div class="div2">2</div>
<div class="div3">3</div>
<div class="div4">4</div>
</body>
</html>
View Code

技术分享

 

CSS float

标签:快速   style   display   code   演示   img   pre   att   nbsp   

原文地址:http://www.cnblogs.com/lcgsmile/p/6626810.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!