当前位置:网站首页>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'
})
},
}
边栏推荐
猜你喜欢
随机推荐
npm init vite-app <project-name> 报错 Install for [‘[email protected]‘] failed with code 1
Machine learning algorithm for large factory interview (6) time series analysis
Spark常见面试问题整理
Celery异步发送短信
[C language] what is a function? Classification and emphasis of functions (help you quickly classify and remember functions)
Pycharm occupies C disk
Getting started with RPC and thrift
flex+js实现内部盒子高度跟随其中最大的高度
页面实现 “实时数据响应” 的注意事项
Differences and basic operations of shell/sh/bash
TypeScript 常用类型
The super simple face recognition API can realize face recognition in just a few lines of code
Install pyGame using CMD
Anti shake and throttling of JS
When v-show is used with display:flex in the uni app applet, v-show does not take effect!
解决手动查询Oracle数据库时间格式不正确的问题(DATE类型)
视图的使用
pycharm如何正确打包ocr且让打包出来的exe尽量小
再见if-else
Project process summary

![[pytho-flask笔记5]蓝图简单使用](/img/0a/00b259f42e2fa83d4871263cc5f184.png)





