• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
pengpenglin
乐于工作,享受生活。
博客园    首页    新随笔    联系   管理    订阅  订阅
css实现自适应宽度布局

1.实现左侧宽度固定,右侧全屏自适应。

body{margin:0;padding:0}
.wrap{ width:100%; float:left}
.content{ height:300px;background:green; margin-left:200px}
.right{ width:200px; height:300px; background:red; float:left; margin-left:-100%}

<body>
<div class="wrap">
    <div class="content">content</div>
</div>
<div class="right">aside</div>
</body>

 

2.实现左侧与右侧宽度固定,中间部分全屏自适应。

<style type="text/css">
body{margin:0;padding:0}
.wrap{ width:100%; float:left}
.content{ height:300px;background:green; margin-left:200px;margin-right:200px}
.left{ width:200px; height:300px; float:left; background:yellow; margin-left:-100%}
.right{ width:200px; height:300px; background:red; float:left; margin-left:-200px}
</style>

<body>
<div class="wrap">
    <div class="content">content</div>
</div>
<div class="left">aside</div>
<div class="right">aside</div>
</body>

 

posted on 2015-08-01 17:54  pengpenglin  阅读(1477)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3