Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equal height items #9154

Closed
studioraygun opened this issue Jan 28, 2018 · 17 comments
Closed

Equal height items #9154

studioraygun opened this issue Jan 28, 2018 · 17 comments

Comments

@studioraygun
Copy link

studioraygun commented Jan 28, 2018

What problem does this feature solve?

When using the Card component it would be great to add support for equal heights. Similarly, when using Row and Col, if we could add support for equal heights on all children of a Row item, it would solve a lot of layout issues.

What does the proposed API look like?

<Row equal-heights> or similar

@yutingzhao1991
Copy link
Contributor

I don't understand,What does a lot of layout issues mean?

Row height === max(Col height) so it will not bring layout issues. https://codesandbox.io/s/my8p6vk7wj

@studioraygun
Copy link
Author

I mean add a feature to make the columns (and other elements) equal heights inside a row.

Your example currently looks like this:

screen shot 2018-01-29 at 09 33 56

But it would be nice to add <Row equal-heights> and the content appear as so:

screen shot 2018-01-29 at 09 35 56

@yutingzhao1991
Copy link
Contributor

I see ... It looks reasonable.

Maybe call vertical-fill better ?

@afc163
Copy link
Member

afc163 commented Feb 1, 2018

I don't think we need this, the height of children should leave to children's content or it's style.

@afc163 afc163 closed this as completed Feb 1, 2018
@birendra-90
Copy link

birendra-90 commented Sep 8, 2018

@yutingzhao1991 @ddcat1115 I am getting the same issues. Any have a solution for that?

@sgwcollins
Copy link

Any resolution on this issue?

@birendra-90
Copy link

nope

@alvin
Copy link

alvin commented Oct 28, 2018

Using flexbox-enabled rows with type="flex" and setting the height to 100% on the column contents worked well for me.

<Row gutter={16} type="flex">

https://ant.design/components/grid/#Row

image

@youlinaXealth
Copy link

Thanks Alvin. It works for me to set type='flux'. But don't forget to set the height to 100% on the column contents also. Not column itself, it should be the component under column.

@rsrogers4
Copy link

rsrogers4 commented May 6, 2019

I have Cards in my grid. Setting row type to "flux" and the card's height to "100%" (as suggested in this thread) works perfectly in the sense that each card fills the full height of the row. However, the card's action bar is no longer at the bottom of the row. It looks like this:

image

How can I have cards in a grid that expand to the height of the row, and with the card action buttons at the bottom of the row?

@dianaabv
Copy link

dianaabv commented Aug 21, 2019

in the Meta tag you can add a class and specify your fixed height. Like

<Card>
 <Meta  
  className="cardBodyStyle"
  title={key.title}
  description={key.description}
 />
</Card>

css:

.cardBodyStyle {
    height: 100px;
}

@milad1367
Copy link

Using flexbox-enabled rows with type="flex" and setting the height to 100% on the column contents worked well for me.

<Row gutter={16} type="flex">

https://ant.design/components/grid/#Row

image

this is the right way

@pavloneiman
Copy link

Try this approach to stretch child node to all available space (vertically and horizontally)

<Row gutter={16}>
    <Col span={12} style={{display: 'flex'}}>
        <Card style={{flex:1}}>
            1<br/>2<br/>3
        </Card>
    </Col>
    <Col span={12} style={{display: 'flex'}}>
        <Card style={{flex:1}}>
            1<br/>2
        </Card>
    </Col>
</Row>

@cromat
Copy link

cromat commented Jun 25, 2020

For me, none of these were working. The solution was to remove height: 100% and set display: inline-flex and align-self: stretch on Col tags. If you have multiple elements inside Col, you'll need to wrap them within another container so that the Col has only one child.

@Knive
Copy link

Knive commented Mar 21, 2022

If someone is interested in the case you are using a Card component inside a Col as @studioraygun intended and you have the same issue as @rsrogers4, here is how you get equal heights body cards:

TLDR :

  • Set display: flex on Col and inner Card components
  • Add flex-direction: column on inner Card component
  • Set flex-grow: 1 on .ant-card-body

Example :

<Row gutter={16}>

    <Col style={{ display: 'flex' }}>
        <Card
            className='flexible-card'
            style={{ display: 'flex', flexDirection: 'column' }}
            actions={[
                <SettingOutlined key="setting" />,
                <EditOutlined key="edit" />,
                <EllipsisOutlined key="ellipsis" />,
            ]}
        >
            <Meta title="Card title" description="This is the description"/>
        </Card>
    </Col>
    
    <Col style={{ display: 'flex' }}>
        <Card
            className='flexible-card'
            style={{ display: 'flex', flexDirection: 'column' }}
            actions={[
                <SettingOutlined key="setting" />,
                <EditOutlined key="edit" />,
                <EllipsisOutlined key="ellipsis" />,
            ]}
        >
             <Meta title="Card title" description="This is an even longer description to show the card body growing"/>
        </Card>
    </Col>
    
</Row>

And have written in your css :

.flexible-card .ant-card-body {
    flex-grow: 1
}

Instead of this:
image

You will get this:
image

@yarinsa
Copy link

yarinsa commented Mar 31, 2022

If someone is interested in the case you are using a Card component inside a Col as @studioraygun intended and you have the same issue as @rsrogers4, here is how you get equal heights body cards:

TLDR :

  • Set display: flex on Col and inner Card components
  • Add flex-direction: column on inner Card component
  • Set flex-grow: 1 on .ant-card-body

Example :

<Row gutter={16}>

    <Col style={{ display: 'flex' }}>
        <Card
            className='flexible-card'
            style={{ display: 'flex', flexDirection: 'column' }}
            actions={[
                <SettingOutlined key="setting" />,
                <EditOutlined key="edit" />,
                <EllipsisOutlined key="ellipsis" />,
            ]}
        >
            <Meta title="Card title" description="This is the description"/>
        </Card>
    </Col>
    
    <Col style={{ display: 'flex' }}>
        <Card
            className='flexible-card'
            style={{ display: 'flex', flexDirection: 'column' }}
            actions={[
                <SettingOutlined key="setting" />,
                <EditOutlined key="edit" />,
                <EllipsisOutlined key="ellipsis" />,
            ]}
        >
             <Meta title="Card title" description="This is an even longer description to show the card body growing"/>
        </Card>
    </Col>
    
</Row>

And have written in your css :

.flexible-card .ant-card-body {
    flex-grow: 1
}

Instead of this: image

You will get this: image

You helped me a lot thanks!!

@brhanegiday
Copy link

For me, none of these were working. The solution was to remove height: 100% and set display: inline-flex and align-self: stretch on Col tags. If you have multiple elements inside Col, you'll need to wrap them within another container so that the Col has only one child.

This has worked for me. Also make sure that the child of Col have width:100% so that it can span fully.
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests