当前位置:网站首页>flex布局缺点
flex布局缺点
2022-08-08 05:35:00 【Cirrod】
1.兼容性
flex布局在pc端,移动端,小程序等都可以使用,但是针对各个浏览器有兼容性问题,主要是IE浏览器的兼容性问题,IE浏览器版本需要IE9以上才能使用flex布局

2.垂直方向的布局属性失效
当盒子的高度不确定(由内容的高度把盒子挤开时),即不设置盒子的高度时,此时不适合使用flex布局
应用场景:

如上图所示:
当我们的列表项不确定有多少个时 ,我们就不能给父盒子设置高度,因为flex布局在父盒子没有确定的高度时,垂直方向的属性会失效(没有效果),
例如给列表父盒子设置下列属性会失效的:
flex-direction: column;
justify-content: space-between;这时我们就需要使用magin和padding等实现上图效果
3.案例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
ul {
background: pink;
display: flex;
flex-direction: column;
justify-content: space-between;
}
li {
margin-top: 10px;
width: 100px;
height: 100px;
background: red;
}
</style>
</head>
<body>
<div>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</body>
</html>浏览器中

可以看到ul标签的justify-content: space-between并没有生效
4.总结
flex布局的优点特别多,使用flex布局和定位能快速完成布局效果,也是我们开发页面时最常用的技术,但是felx布局对IE版本9以下有兼容性的问题和当父盒子没有设置高度时在垂直方向无法使用flex布局
边栏推荐
猜你喜欢

浅学软件逆向笔记(1)

研发医疗器械产品需要做的测试

The difference between classification, object detection, semantic segmentation, and instance segmentation

Postman显示验证码图片(base64字符串)

IP核之RAM实验

为什么互联网大厂一边疯狂裁员,一边不停招聘?

Redis In Action —— Advanced —— 数据主从同步原理 —— 全量同步 与 增量同步 工作流程及原理 —— 以及如何利用 docker 容器技术快速模拟单机 Redis 集群

千亿级、大规模:腾讯超大 Apache Pulsar 集群性能调优实践

postgresql中连接两张表更新第三张表(updata)

postman---postman参数化
随机推荐
String title parsing
121道分布式面试题和答案
Web 攻击的日志分析:初学者指南
Eighteen, OIDC OAuth2 】 【 the understanding of the application
Hundreds of billions, large-scale: performance tuning practice of Tencent's super-large Apache Pulsar cluster
Day8:面试必考编程题(细心OJ)
automation tool
The difference between CHAR_LENGTH() and LENGTH() in MySQL
TSF Microservice Governance Combat Series (2) - Service Routing
76. The minimum cover substring
Session and cookie usage
C language framework FreeSwitch custom event introduction and usage example
神经网络参数量和计算量,神经网络是参数模型吗
C语言框架FreeSwitch自定义事件介绍与使用示例
Leetcode sword 】 refers to the Offer (special commando) summary
Servlet---ServletConfig类使用介绍
Unity mouse cursor usage learning
Hard Disk Basics
【Win10】Several sleep problems and countermeasures
Connect two tables to update the third table (updata) in postgresql