当前位置:网站首页>左侧固定,右侧自适应 三种实现办法(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>边栏推荐
- 第十六届东北地区大学生程序设计竞赛(热身赛)B-String Value(字符串dp)
- 3 天完成小学期项目,手把手教你完成天气播报系统!
- The tiobe programming language ranking is an indicator of the popular trend of programming languages
- BGP experiment
- Servlet self study notes
- Hcip reissue experiment
- Mongodb sharding principle
- BGP实验
- Get bat command results in bat
- Architecture à trois niveaux MVC
猜你喜欢
随机推荐
Hcip reissue experiment
Hcip fifth operation
Visual display of TEQC quality analysis results using teqcplot
618 how to break through the siege? Haier Zhijia: do a good job in digitalization of users
(IntelliJ)插件一 Background Image Plus
经济发展由新技术推动着来
C'est dur de trouver un emploi? Ali des trois côtés, heureusement qu'il s'est bien préparé et qu'il a pris un produit.
I have been engaged in software testing for 5 years and have changed jobs for 3 times. I have understood the field of software testing
搭建一套 gocd 的环境
What are the main aspects of visual improvement brought by introducing AI into ISP Technology
直接插入排序——【常见排序法(1/8)】
Cookie-Session讲解
Difficult to find a job in a bad environment? Ali on three sides. Fortunately, he has made full preparations and has offered
PHP move_ uploaded_ File failed to upload mobile pictures
3 天完成小学期项目,手把手教你完成天气播报系统!
组合式API-composition-api
Go 分组 & 排序
OSPF分流实验
Three tier architecture experiment
In unity, how to read and write a scriptableobject object in editor and runtime








