Bootstrap 浮动

(1)浮动

pull-left

pull-right

(2)清除浮动

clearfix

复制代码
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>

<body>

    <div class="container-fluid">
        <div class="row clearfix">

            <div class="col-md-12 column">
                <div class="pull-left bg-info">div</div>
                <div class="pull-right bg-info">div</div>
                <div class="center-block" style="width:150px;background-color:#ccc;">该 div 显示在中间</div>
                <div class="pull-left bg-info">div2-left</div>
                <div class="pull-right bg-info">div2</div>
                <div class="center-block" style="width:150px;background-color:#ccc;">该 div2 显示在中间</div>
                <div class="bg-success text-center" style="width: 100px;display: block;margin: auto;">123456</div>
            </div>


        </div>
    </div>

</body>

</html>
View Code
复制代码

未添加清除浮动

复制代码
<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap .clearfix 实例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">  
  <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
  <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container-fluid">
    <div class="clearfix"  style="background: #D8D8D8;border: 1px solid #000;padding: 10px;">
        <div class="pull-left" style="background:#58D3F7;">
          向左快速浮动
        </div>
        <div class="pull-right" style="background: #DA81F5;">
          向右快速浮动
        </div>
      </div>
</div>

</body>
</html>
View Code
复制代码

添加清除浮动

 

posted @   南风丶轻语  阅读(245)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示
点击右上角即可分享
微信分享提示