简体   繁体   English

如何使两个不同的组件具有相同的高度

[英]How can I make two different components the same height

I have a react card that can render two different things depending on a whether or not a certain prop is active. 我有一个反应卡,可以根据某个道具是否激活来渲染两种不同的东西。 How can I ensure that the two different things are the same height, as the cards are not the same size when I put them next to each other? 当我将它们并排放置时,如何确保两个不同的物体的高度相同,因为它们的尺寸不一样?

Here is the code: 这是代码:
<div className={cardInfoClasses}> <h3 className={titleClasses}>{this.props.name}</h3> {cardMain} </div>

cardMain can either be: cardMain可以是:
<div> <Progress productData={productData} className='mobile_hide'/> </div>; or 要么
<CardButton initialData = {this.props.data}/>

You can accomplish that with display flex or table. 您可以使用display flex或table完成。 You give the parent display flex and adjust other properties like justify-elements and width. 您可以为父级显示提供柔韧性,并调整其他属性,例如justify-elements和width。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM