当前位置:网站首页>Flex+js realizes that the height of the internal box follows the maximum height
Flex+js realizes that the height of the internal box follows the maximum height
2022-07-23 11:23:00 【A big river depends on waves】
effect
1、 All the small cards inside are in one line , Beyond plus horizontal scroll bar ;
2、 The height of each card follows the height of the highest card inside :

Realization
1、 First, the parent frame of the whole package card , His height must follow the maximum card height inside . Dynamically set here height, In order to flex Layout , To meet the above style ,flex The parent must have a height , Not for auto
<div class="ind-type-group" ref="group" :style="{height: groupHeight}">
<!-- Multiple cards -->
<ind-type-card class="type"></ind-type-card>
<ind-type-card class="type"></ind-type-card>
...
</div>
2、 flex style (gap Use with caution , Browser compatibility is not good )
.ind-type-group {
display: flex;
align-items: stretch; // The internal card is highly stretched
width: 100%;
overflow: auto;
padding-bottom: 20px; .type {
flex: 1;
min-width: 400px;
max-width: calc((100% - 40px)/3);
}
.type + .type {
margin-left: $gap4x;
}
}
// Card style .ind-type-card {
height: 100%;
width: 100%;
}
3、 adopt js Dynamically set the parent height
data() {
return {
groupHeight: 'auto', // Initial settings auto
}
},
mounted() {
this.getAllTypes()
window.addEventListener('resize', this.setHeight)
},
beforeDestroy() {
window.removeEventListener('resize', this.setHeight)
},
methods: {
// The height is not fixed , All items are based on the highest
setHeight() {
this.groupHeight = 'auto'
this.$nextTick(() => {
// Get the parent height dynamically , And set up height, This setting is mainly for flex Of stretch Set height reference
this.groupHeight = this.$refs.group.clientHeight + 'px'
})
},
}
边栏推荐
- 大米商城注册
- Request data acquisition and response
- my_ Implementation of strcpy (classic, simple, practical, collection)
- Fun code rain, share it online~-
- The attribution of branch and loop statements in C language
- The super simple face recognition API can realize face recognition in just a few lines of code
- Analysis of two-part search method or half search method of C language (classic example, classic analysis)
- Application of higher-order functions: handwritten promise source code (II)
- C语言中的流氓goto语句
- 同步发送短信验证码
猜你喜欢

PyGame realizes the airplane war game

C语言调试常见错误——简答

The problem that GBK codec cannot decode may be caused by the file name

【C语言】什么是函数?函数的分类和侧重(帮你快速分类和记忆函数)

TypeScript 高级类型

systemctl-service服务添加环境变量及模板

flex+js实现内部盒子高度跟随其中最大的高度

Web server failed to start. Port 8080 was already in use.

Burpsuite learning notes

Scattered notes of machine learning: some concepts and notes
随机推荐
JS class array objects and methods of class array conversion (ES6, Es5)
After the formula in word in WPS is copied, there is a picture
C语言调试常见错误——简答
用getchar清理缓冲区(强烈推荐,C语言易错典型)
使用el-table懒加载树形表格时的注意点
Rice mall registration
简单实现矩形面积块
高阶函数的应用:手写Promise源码(三)
py程序可以运行,但打包出的exe运行提示错误:加载“cv2”二进制扩展时检测到递归。请检查OpenCV安装。
View set and route
大厂面试机器学习算法(0):特征工程 | 数据预处理
Error handling of "listener not started or database service not registered" in Oracle database creation
my_ Implementation of strcpy (classic, simple, practical, collection)
JS higher order function
gbk编解码器无法解码的问题,有可能出题出在文件名上
TypeScript 常用类型
Inheritance mode of JS
机器学习中的矩阵向量求导
RPC与thrift入门
[监控部署实操]基于granfana展示Prometheus的图表和loki+promtail的图表