当前位置:网站首页>左侧固定,右侧自适应 三种实现办法(Flex,float + BFC ,float-margin-left)
左侧固定,右侧自适应 三种实现办法(Flex,float + BFC ,float-margin-left)
2022-06-23 03:55:00 【PHP代码】
//结构
<div class="demo">
<div class="left"></div>
<div class="right"></div>
</div>
1.Flex
<style>
* {
padding: 0;
margin: 0;
}
.demo {
overflow: hidden;
display: flex;
}
.left {
width: 200px;
height: 200px;
background-color: red;
}
.right{
height: 200px;
background-color: aquamarine;
flex: 1;
}
</style>
2.float + BFC
<style>
* {
padding: 0;
margin: 0;
}
.demo {
overflow: hidden;
}
.left {
width: 200px;
height: 200px;
background-color: red;
float: left;
}
.right {
height: 200px;
background-color: aquamarine;
/* 形成BFC盒子 */
overflow: auto;
}
</style>3.float + margin-left
<style>
* {
padding: 0;
margin: 0;
}
.demo {
/* 清除浮动 */
overflow: hidden;
}
.left {
width: 200px;
height: 200px;
background-color: red;
float: left;
}
.right {
height: 200px;
background-color: aquamarine;
/* 固定盒子的宽度 */
margin-left: 200px;
}
</style>边栏推荐
- The technological advance of new employees? Journey
- 【Mac】安全性与隐私中没有任何来源选项
- BGP second test
- Servlet self study notes
- In unity, how to read and write a scriptableobject object in editor and runtime
- VMware network connection error unit network service not found
- vmware网络连接出错Unit network.service not found
- Onnxoptimizer, onnxsim usage records
- Implementation of the rotation chart
- Missing essential plugin
猜你喜欢

Zygote process

JSP entry notes

LeetCode 797:所有可能的路径

Drag and drop frame

李宏毅《机器学习》丨5. Tips for neural network design(神经网络设计技巧)

搭建一套 gocd 的环境

Difficult to find a job in a bad environment? Ali on three sides. Fortunately, he has made full preparations and has offered

开源生态|超实用开源License基础知识扫盲帖(下)

Web application security testing guide

Three tier architecture experiment
随机推荐
SwiftUI 2.0 课程笔记 Chapter 4
物联网开源开发平台 Shifu 开放内测!第一版技术文档发布
Event日志关键字:EventLogTags.logtags
气象绘图软件Panoply使用教程 (不定时更新)
Ams:startactivity desktop launch application
Penetration test basis | attached test points and test scenarios
HCIP 重发布实验
飞桨框架v2.3发布高可复用算子库PHI!重构开发范式,降本增效
JSP entry notes
BGP实验
TIOBE 编程语言排行榜是编程语言流行趋势的一个指标
CF【1700D】D. River Locks(dp、二分、数学)
Hard core, become a high-quality tester: learn to communicate with products
Direct insertion sort - [common sort method (1/8)]
HCIP 作业 BGP总结
In unity, how to read and write a scriptableobject object in editor and runtime
insert into... Where not exists insert to avoid repeated use
OSPF shunt test
Fund performance evaluation
Servlet self study notes