0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

高さが均等になるように要素を並べる

Last updated at Posted at 2020-11-18

高さが均等になるように要素を並べる。

・flex: 1を使うことで各要素の高さが均等になる

.parent {
    display: flex;
    justify-content: center;
}

.item {
    display: flex;
    flex-direction: column;
    background-color: cadetblue;
    margin: 0 8px;
    padding: 8px;
}

.item p {
    flex: 1;
}
import React from 'react'
import './Hoge.css'

export const Hoge = () => {
    return (
        <>
            <div className="parent">
                <div className="item">
                    <p>aaaaaaaaaaaaaaaaa</p>
                    <button>button</button>
                </div>
                <div className="item">
                    <p>aaaaaaaa<br />aaaaaaaaa</p>
                    <button>button</button>
                </div>
                <div className="item">
                    <p>aaaaaaaaaaaaaaaaaaaaa<br />aaaaaaaaaaa<br />aaaaaaaa<br />aaaaaaaaaaa</p>
                    <button>button</button>
                </div>
                <div className="item">
                    <p>aaaaaaaaaaaaaaaaa</p>
                    <button>button</button>
                </div>
            </div>
        </>
    )
}

結果
スクリーンショット 2020-11-18 22.43.47.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?