码迷,mamicode.com
首页 > 其他好文 > 详细

左右布局

时间:2019-01-17 12:49:10      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:ima   技术分享   image   flex   rip   neu   idt   网格   inf   

1、左侧不居中

技术分享图片

 

css:

 

<style>
   /*float*/
  .s-left{float: left;width: 70px;}
  .s-right{margin-left: 70px;}
  /*flex*/
  .d-flex{display: flex;}
  .d-left{flex: 0 0 70px;}
  /*table*/
  .t-table{display: table;}
  .t-left{display: table-cell;width: 70px;    }
</style>

 

html:

<div style="width:400px;">
        <h4 class="margin-bottom20">1、bootscript网格</h4>
        <div class="row">
            <div class="col-md-12">
                 <div class="col-md-2">选择</div>
                 <div class="col-md-10">
                    <button class="btn btn-default">1</button>
                 </div>
            </div>
         </div>
         <hr>
         <h4 class="margin-bottom20">2、左浮动,width + 右margin-left</h4>
         <div style="position:relative">
           <div class="s-left text-center">
                <span class="sp">选择</span>
             </div>
             <div class="s-right">
                <button class="btn btn-default">1</button>
             </div>
         </div>
         <hr>
         <h4 class="margin-bottom20">3、display:flex+ 左flex: 0 0 70px;</h4>
         <div class="d-flex">
             <div class="d-left text-center">选择</div>
             <div class="d-right">
                 <button class="btn btn-default">1</button>
             </div>
         </div>
         <hr>
         <h4 class="margin-bottom20">4、display:table + 左table-cell,width</h4>
         <div class="t-table">
            <div class="t-left text-center">选择</div>
            <div class="t-right">
                <button class="btn btn-default">1</button>
            </div>
         </div>
    </div>
 

左右布局

标签:ima   技术分享   image   flex   rip   neu   idt   网格   inf   

原文地址:https://www.cnblogs.com/yuyedaocao/p/10281533.html

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