![初心者プログラマ日記__1_](https://assets.st-note.com/production/uploads/images/13657350/rectangle_large_type_2_8116182a1a6cee2bb33289ddbbec0cee.png?width=1200)
Flexboxの align-items: center; が効かないときの対処法
![画像1](https://assets.st-note.com/production/uploads/images/13657381/picture_pc_8efa1dfec7b1cc410b4f0dc9bbdc2b27.png?width=1200)
解決したいこと
ヘッダーメニューの作成時に、ロゴとメニューアイテムを縦方向にセンタリングしたい。flexboxでalign-items: center;を指定しても効かない。
原因と解決方法
.header {
background-color: #3f51b5;
height: 100px;
width: 100%;
.header-inner {
padding: 0 140px;
display: flex;
justify-content: space-between;
align-items: center;
}
.header にheight: 100px;が指定されているのが原因。
.header-innerに指定し直す。
.header {
background-color: #3f51b5;
width: 100%;
.header-inner {
padding: 0 140px;
display: flex;
justify-content: space-between;
align-items: center;
height: 100px;
}
![画像2](https://assets.st-note.com/production/uploads/images/13657621/picture_pc_a418863078d8cb296fbbae0fee6853e2.png?width=1200)
無事解決。
こんな商品もつくっています👇🏻
いいなと思ったら応援しよう!
![Teru](https://assets.st-note.com/production/uploads/images/29818370/profile_0aa34f9a99bc47dd28e77aa4b75575fc.jpeg?width=600&crop=1:1,smart)