实现一个div,左边固定div宽度200px,右边div自适应
实现一个div,左边固定div宽度200px,右边div自适应
<div class= "container">
<div class="left"></div>
<div class="rigth"></div>
</div>
<style>
/*方法一: BFC(块级格式化上下文)*/
.container{
width:1000px;height:400px;border: 1px solid red;
}
.left{
width:200px;height:100%;background: gray;
float: left;
}
.rigth{
overflow:hidden; /* 触发bfc */
background: green;
}
/*方法二: flex布局 */
.container{
width:1000px;height:400px;border:1px solid red;
display:flex; /*flex布局*/
}
.left{
width:200px; height:100%;background:gray;
flex:none;
}
.right{
height:100%;background:green;
flex:1; /*flex布局*/
}
/* 方法三: table布局 */
.container{
width:1000px;height:400px;border:1px solid red;
display:table; /*table布局*/
}
.left{
width:200px; height:100%;background:gray;
display:table-cell;
}
.right{
height:100%;background:green;
display: table-cell;
}
/*方法四: css计算宽度calc*/
.container{
width:1000px;height:400px;border:1px solid red;
}
.left{
width:200px;height:100%;background:gray;
float:left;
}
.right{
height:100%;background:green;
float:right;
width:calc(100% - 200px);
}
</style>
---------------------------------------------------------------------------------------------------
<div style="width:100%;height:auto;overflow:hidden">
<div style="float:left;width:200px;height:auto;min-height:300px;background:#f00">左边固定宽度</div>
<div style="margin-left:200px;width:100%">右边撑满剩余宽度</div>
实现一个div,左边固定div宽度200px,右边div自适应的更多相关文章
- NO.14 两个div并排,左边为绝对宽度,右边为相对宽度
两个div并排,左边为绝对宽度,右边为相对宽度,这个问题,我也经常遇到,我一般的处理方法是将最大的容器padding-left固定宽度,左边的固定宽度的一块position:absolute,然后ri ...
- css网页布局 --- 左边固定,右边自适应
div的布局统一如下: <body> <div class="wrap"> <div class="left"></d ...
- DIV+CSS布局问题:一个宽度不确定的DIV里面放三个水平对齐的DIV,左右两个DIV宽度固定为150px,中间那个DIV充满剩余的宽度
一个入门的DIV+CSS布局问题:一个宽度不确定的DIV里面放三个水平对齐的DIV,左右两个DIV宽度固定为150px,中间那个DIV充满剩余的宽度. 说明:代码非真实情况下使用,所以直接简单. 没耐 ...
- 实现左边div固定宽度,右边div自适应撑满剩下的宽度的布局方式:
html: <div class="container"> <div class="left"> left固定宽度200px </ ...
- 设置一个DIV块固定在屏幕中央(两种方法)
设置一个DIV块固定在屏幕中央(两种方法) 方法一: 对一个div进行以下设置即可实现居中. <style> #a{ position: fixed; top: 0px; left: 0p ...
- 实现三个div,固定左右两边的div宽为200,中间的div宽度自适应的四种方法
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- div左边固定宽度,右边自适应宽度
样式: <style type="text/css"> html,body { height: 100%; padding: 0; margin: 0; } .oute ...
- CSS 左边div固定,右边div自适应
有时候我们会有这样的需求,如图,aside是导航或者某些链接,右边的main是显示重要的内容,左边需要定宽,右边的main能够自适应剩余的宽度: <!DOCTYPE html PUBLIC &q ...
- css实现左边div固定宽度,右边div自适应撑满剩下的宽度
(1)使用float <div class="use-float"> <div></div> <div></div> & ...
随机推荐
- Android——Service装取数据
在Service里面装数据,从Activity里面用serviceConnection取数据 xml <?xml version="1.0" encoding="u ...
- log4写完日志不会自动释放
今天想做个日志记录功能.网上查了下.决定使用log4net 来做. 但是最发现在写日志的时候.会一直占用当前的日志文件.当你想查看的时候会提示另一个进程占用了该文件. 只有到他创建下一个日志文件.然后 ...
- CSS(九):设置盒子水平垂直居中
通过设置下面的样式可以使盒子水平垂直居中: <!DOCTYPE html> <html lang="en"> <head> <meta c ...
- resttemplate 文件上传 上传文件
springmvc RestTemplate文件上传 RestTemplate上传文件总结
- CSS Notes
Margin vs. PaddingMargin is on the outside of block elements while padding is on the inside. Use mar ...
- [Intellij] Project Structure 配置说明
IntelliJ IDEA 的Project structure可以在File->Project structure中打开,同时,在新建项目是IDE一般用向导的方式让你填写Project str ...
- Semantic segmentation using adversarial networks
FAIR Paris分部的论文,NIPS2016 Workshop. Motivation是让predict出来的结果和真实label在高层感觉上有一致性. 基本思想就是用GAN来区分segmenta ...
- linux 将终端进行换行
原始 修改 修改方法 vim .bashrc fi if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debia ...
- VIM中一些按键的作用:
表示范围的命令: l: 表示一个字符,可以于操作符组合使用: aw :表示一个单词: 不会count 空格: 前面可以加数字的: iw: 选中一些单词, 会包括空格: 前面可以加数字: ap: 表 ...
- Java数组扩展
Java中,数组初始化后如何扩展数组? 示例 以下示例显示如何在创建新并初始化数组后扩展数组. package com.yiibai; public class ExtendingArray { pu ...