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

右定宽左自适应篇

 

    1.float + margin

html:

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

css:

.container{margin:0 auto;}
.left{background:blue;margin-right:-100px;width:100%;float:left;}
.right{float:right;width:100px;background:orange;}

  

效果图:

提示:实际上是背景等高!!!

    2.table

html:

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

css:

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

  效果图:

 

    3.flex

html:

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

  css:

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

  效果图:

 

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