• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
向阳光大道勇猛前进吧,了解但不走偏门!
            管理     

左定宽右自适应篇

 

    1.flloat + margin

html:

<div class=".container"> 
	<div class="left"> 
		<p>我在左边哦</p>
	</div> 
	<div class="right"> 
		<p>我在右边哦</p>
		<p>我在右边哦</p> 
	</div> 
</div> 

css:

.left {float: left;width: 100px;}
.right {margin-left: 2300px}

 效果图:

 

    2.float + overflow

html:

<div class=".container"> 
	<div class="left"> 
		<p>我在左边哦</p>
	</div> 
	<div class="right"> 
		<p>我在右边哦</p>
		<p>我在右边哦</p> 
	</div> 
</div> 

  css:

.left { float: left;width: 100px;}
.right {overflow: hidden;}

  效果图:

 

    3.table

html:

<div class=".container"> 
	<div class="left"> 
		<p>我在左边哦</p>
	</div> 
	<div class="right"> 
		<p>我在右边哦</p>
		<p>我在右边哦</p> 
	</div> 
</div> 

  css:

.container{display: table;width: 100%;table-layout: fixed;}
.left {display: table-cell;width: 100px;}
.right {display: table-cell;}

  

效果图:

 

    4.flex

html:

<div class=".container"> 
	<div class="left"> 
		<p>我在左边哦</p>
	</div> 
	<div class="right"> 
		<p>我在右边哦</p>
		<p>我在右边哦</p> 
	</div> 
</div> 

  css:

.container{display: flex;}
.left {width: 100px;margin-left: 20px;}
.right { flex: 1;}

  

效果图:

    

 

圣凡无二路,方便有多门。
posted @ 2018-03-03 02:21  优昙陀罗  阅读(214)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3