css布局:左边固定宽度,右边自适应;右边固定宽度,左边自适应
左边固定宽度,右边自适应
浮动布局的方法
<section class="container homeSection" id="mainSection">
<div class="content-wrap">
222
</div>
<div class="rightSide">
333
</div>
</section> <style lang="scss">
.homeSection {
overflow: hidden;
.content-wrap {
float: left;
width: 200px;
background-color: #fff;
}
.rightSide {
margin-left: -200px;
background: #F0AD4E;
}
}
</style>
绝对定位的方法:
<section class="container homeSection" id="mainSection">
<div class="content-wrap">
<div class="bannerFloor">
122
</div>
</div>
<div class="rightSide">
333
</div>
</section>
<style>
.homeSection {
position: relative;
.content-wrap {
position: absolute;
left: 0;
width: 200px;
}
.rightSide {
position: absolute;
left: 200px;
right: 0;
} }
</styles>
还有就是 flex 布局喽,大家应该都知道,就不写了。
左边固定宽度,右边自适应
浮动方法
以下是html代码,与上面有所不同的是,书写代码的时候,right代码在前面
<section class="container homeSection" id="mainSection">
<div class="rightSide">
333
</div>
<div class="content-wrap">
<div class="bannerFloor">
<p>
你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁
</p>
</div>
</div> </section>
.homeSection {
overflow: hidden;
.content-wrap {
background-color: #fff;
margin-right: 200px;
}
.rightSide {
float: right;
width: 200px;
background: #F0AD4E;
}
}
另一种浮动的方法:需要给左边自适应的元素一个父元素, 如文中的content-wrap
<section class="container homeSection" id="mainSection">
<div class="content-wrap">
<div class="bannerFloor">
<p>
你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁你是谁
</p>
</div>
</div>
<div class="rightSide">
333
</div>
</section>
.content-wrap {
float: left;
.bannerFloor {
margin-right: 200px;
}
}
.rightSide {
float: left;
width: 200px;
margin-left: -200px;
background: #F0AD4E;
}
同意的,它也有 绝对定位 跟 flex 的方法,不一一的列出来了。
更详细的内容可以访问 http://www.waigai.cn
css布局:左边固定宽度,右边自适应;右边固定宽度,左边自适应的更多相关文章
- 如何用纯CSS布局两列,一列固定宽度,另一列自适应?
大家都知道好多网站都是左右布局的,很多公司在笔试和面试环节也常常问这个问题.一个去网易的师兄说14年腾讯面试的时候问过这个问题,网易在笔试和面试时候也问过这个问题,还有很多互联网公司也都涉及到这个问题 ...
- css布局:左边固定宽度,右边自适应宽度或右侧固定,左侧自适应三种方法
方法一:浮动布局 这种方法我采用的是左边浮动,右边加上一个margin-left值,让他实现左边固定,右边自适应的布局效果 HTML Markup <div id="left" ...
- css布局:左边定宽、右边自适应
方法一 : 左边 左浮动,右边 margin-left *{margin: 0;padding: 0;} .left{ float: left; width: 200px; border: 1px s ...
- HTML布局之左右结构,左边固定右边跟据父元素自适应
HTML布局之左右结构,左边固定右边跟据父元素自适应,兼容IE6+.Firefox.Chrome.Opera.Safari,这里是用表单写的一个demo,其实就在主体布局中也是可以的,比如像后台一些管 ...
- css实现左(右)侧固定宽度,右(左)侧宽度自适应 ---清除浮动
老话长谈,css的不固定适应布局 不管是面试还是在平时的工作中,这样的布局形式一直都在用着,很常见,所以今天我就拿出来在唠叨一下, 既是给自己一个备忘存储,也是一个学习巩固的参考,知道大家都会,还 ...
- Css中实现一个盒子固定宽度,另一个盒子宽度自适应的方法
Css中实现一个盒子固定宽度,另一个盒子宽度自适应的方法 网上方法很多,个人认为以下两种思想是最为常用的. 一种是让第一个盒子脱离文档流,第二个盒子离左边有一定距离. 第二种方法是使用flex布局,不 ...
- css中如何实现左边的高度随着右边改变而改变
css中如何实现左边的高度随着右边改变而改变 html结构: <div class="main"> <div class="main_left" ...
- CSS 布局实例系列(三)如何实现一个左右宽度固定,中间自适应的三列布局——也聊聊双飞翼
今天聊聊一个经典的布局实例: 实现一个三列布局,其中左侧和右侧的部分宽度固定,中间部分宽度随浏览器宽度的变化而自适应变化 可能很多朋友已经笑了,这玩意儿通过双飞翼布局就能轻松实现.不过,还请容我在双飞 ...
- css布局两边固定中间自适应的四种方法
第一种:左右侧采用浮动 中间采用margin-left 和 margin-right 方法. 代码如下: <div style="width:100%; margin:0 auto;& ...
- DIV+CSS布局中自适应高度的解决方法
div乱跑问题 (文件<DIV+CSS布局中自适应高度的解决方法.rar>) float 是个很危险的东西 得小心使用 本来有一很好的关于CSS+DIV的论坛 不过现在关门了 甚是可 ...
随机推荐
- datagridview 添加数据库数据
private void btnadd_Click(object sender, EventArgs e) { string str = @"Data Source=(localdb)\MS ...
- domain
babibobucecicudadedidufafugeguhehujijukakekulalelilumimomunapapipopuqiqurerirusasesisutatetituwawowu ...
- 为git关联编辑器(比如notepad++) Associating text editors with Git
Associating text editors with git Using Notepad++ as your editors you can set your default editor in ...
- css3常用动效以及总结
(迁移自旧博客2017 08 06) CSS3 文本效果: box-shadow:盒子阴影,可以给卡片添加提高美化效果.可广泛应用于内容展示页面. <div class="card&q ...
- Django中的FBV与CBV
一. FBV FBV(function based views) 基于函数的视图, 即一个url对应一个视图函数. 1.1 FBV代码示例 urls.py from django.contrib im ...
- 【搬运工】修改mysql数据库的时区
转载:https://blog.csdn.net/huangyuehong914/article/details/81742039 --------------------- ------------ ...
- threejs绕轴转,粒子系统,控制器操作等(二)
前言:threejs系列的第二篇文章,也是一边学习一边总结: 1,一个物体绕着另一个物体转动 上一篇文中主要是物体自转,为了描述一个一个物体绕另一个物体转,这里我描述了一个月球绕地球公转,并且自转的场 ...
- IOS 模块并且发布到NPM
注释:导入出错 请使用这个 #import <React/RCTBridge.h> 参考文档:http://www.liuchungui.com/blog/2016/05/02/r ...
- vue--vant组件库Dialog弹出框
安装vant UI框架: cnpm install vant –-save-dev 导入组件-在main.js里: import Vant from 'vant'; import'vant/lib/v ...
- virtual box centos7 common operation
======= network part =======1.设置桥接模式 2.vi /etc/sysconfig/network-scripts/ifcfg-enp0s3BOOTPROTO=stati ...