美文网首页前端
css-左右布局

css-左右布局

作者: 墨_梵 | 来源:发表于2018-11-05 13:52 被阅读5次

一、左边固定,右边自适应的布局

1、左边左浮动,右边加个overflow:hidden;
   #lt{ float: left;width:200px; background: #ff0;}
   #rt{ overflow: hidden; background: #f0f;}
2. 左边左浮动,右边加个margin-left;
   #lt{ float: left; width:200px; background: #ff0;}
   #rt{ margin-left: 200px; background: #f0f;}
3. 左边绝对定位,右边加个margin-left
   #lt{ position: absolute; top:0; left:0; width:200px; background: #ff0;}
   #rt{ margin-left: 200px; background: #f0f;}
4. 左右两边绝对定位,右边加个width,top,left,right
   #lt{ position: absolute; top:0 ; left:0 ;width:200px; background: #ff0;}
   #rt{ position: absolute; top:0 ; left:200px; width: 100% ; rigth:0;background: #f0f;}

二、右边固定,左边自适应的布局

1. 左边左浮动,margin-left负值,右边右浮动
   #lt{float:left; width:100%;background: #00f;margin-right: -200px;}
   #rt{float: right; width: 200px;background: #ff0;}
2. 右边绝对定位,左边margin-right
   #lt{margin-right:200px; background: #00f;}
   #rt{ position: absolute; right:0; top:0; width: 200px;background: #ff0;}
3. 左右两边绝对定位,左边加个width,top,left,right
   #lt{ position: absolute; top:0; left:0; rigth:0; width: 100% ; background: #f0f;}
   #rt{ position: absolute; top:0; left:200px; width:200px; background: #ff0;}

相关文章

  • css-左右布局

    一、左边固定,右边自适应的布局 1、左边左浮动,右边加个overflow:hidden; 2. 左边左浮动,右边加...

  • css-布局

    css基础的知识看完后,我们就要学习如何布局,这里详细的总结一下最近了解的布局方式。 一 单列水平居中 1.子元素...

  • css-布局

    关于css布局里,主要的有浮动(float)关键词,可以设置为left/right/;再一个是overflow解决...

  • css-布局

  • css-布局

    历史 1 .table布局2 .float布局3 .fllex布局 默认:正常流布局 1 .在不对页面进行任何布局...

  • CSS-居中布局

    html 结构: css代码: 水平居中 inline-block + text-align table + ma...

  • CSS-弹性布局

        弹性布局对块级元素的布局排列变得十分灵活,适应性非常强,其强大的伸缩性在响应式开发中可以发挥极大的作用。主...

  • css-特殊布局

    作业:上下页切换布局,设置外边距margin的值和内边距的值,在div盒子里面添加列表ul,里层包含li,并且每个...

  • css-布局详解

    正常的默认文档流方式布局就不说了。主要说以下几种布局: table布局 float布局 position定位布局 ...

  • CSS-伸缩布局

    主轴:默认水平方向侧轴:默认垂直方向这两个轴的方向都是可变的,可通过flex-direction来变更,如果将主轴...

网友评论

    本文标题:css-左右布局

    本文链接:https://www.haomeiwen.com/subject/aoksxqtx.html