html 最小宽度 固定,html div 一侧固定,另一侧宽度自适应

一、左侧固定

示例一:

测试

*{

margin: 0;

padding: 0;

}

.main{

width: 100%;

height: auto;

}

.main div{

height: 80px;

}

#left {

float: left;

width: 220px;

background-color: green;

}

#content {

background-color: orange;

margin-left: 220px;/*==等于左边栏宽度==*/

}

Left sidebar
Main Content

示例二:

测试

*{

margin: 0;

padding: 0;

}

.main{

width: 100%;

height: auto;

position: absolute;

}

.main div{

height: 80px;

}

#left {

float: left;

width: 220px;

background-color: green;

}

#content {

background-color: orange;

position: absolute;

top:0px;

right: 0px;

left: 220px;/*==等于左边栏宽度==*/

}

Left sidebar
Main Content

示例三.

测试

* {

margin: 0;

padding: 0;

}

html {

height: auto;

}

body {

margin: 0;

padding: 0;

}

#container {

background: #ffe3a6;

}

#wrapper {

display: inline-block;

border-left: 200px solid #d4c376;/*==此值等于左边栏的宽度值==*/

position: relative;

vertical-align: bottom;

}

#sidebar {

float: left;

width: 200px;

margin-left: -200px;/*==此值等于左边栏的宽度值==*/

position: relative;

}

#main {

float: left;

}

#maing,#sidebar{

min-height: 200px;

height: auto !important;

height: 200px;

}

Main Content

示例四:

测试

* {

margin: 0;

padding: 0;

}

#container{

display: flex;

display: -webkit-flex;

flex-direction: row;

}

#container div{

height: 100px;

}

#sidebar{

background-color: #f09452;

width: 200px;

}

#main{

flex:1;

background-color: #a09f52;

}

Left Sidebar
Main Content

示例五

测试

* {

margin: 0;

padding: 0;

}

#container{

display:table;

width: 100%;

}

#container #wrapper{

display:table-row;

height: 100px;

width: 100%;

}

#container #wrapper div{

display: table-cell;

}

#sidebar{

background-color: #f09452;

width: 200px;

}

#main{

background-color: #a09f52;

}

Left Sidebar
Main Content

二、右侧固定

示例一:

测试

* {

margin: 0;

padding: 0;

}

#container{

width: 100%;

}

#container #wrapper div{

height: 100px;

}

#main{

float: right;

width: 200px;

background-color: #f92;

}

#sidebar{

float: left;

background-color: #29f;

margin-left: -200px;

width: 100%;

}

#container #wrapper:after{

content: ' ';

clear: both;

display: block;

}

Left Sidebar
Main Content

示例二:

测试

* {

margin: 0;

padding: 0;

}

#container{

width: 100%;

}

#container #wrapper{

display: flex;

flex-direction: row;

}

#container #wrapper div{

height: 100px;

}

#main{

width: 200px;

background-color: #f92;

}

#sidebar{

background-color: #29f;

flex:1;

}

#container #wrapper:after{

content: ' ';

clear: both;

display: block;

}

Left Sidebar
Main Content
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值