Flexbox-align-items
提供:Dev Guides
フレックスボックス-アイテムの整列
*align-items* プロパティは、*コンテンツの正当化*と同じです。 しかし、ここでは、アイテムはクロスアクセス全体にわたって(垂直に)並べられました。
使用法-
align-items: flex-start | flex-end | center | baseline | stretch;
このプロパティは、次の値を受け入れます-
- flex-start -フレックスアイテムはコンテナの上部に垂直に配置されました。
- flex-end -フレックスアイテムはコンテナの下部に垂直に配置されました。
- flex-center -flexアイテムはコンテナの中央に垂直に配置されました。
- ストレッチ-フレックスアイテムは、コンテナの垂直方向のスペース全体を埋めるように垂直方向に配置されました。
- baseline -フレックス項目は、テキストのベースラインが水平線に沿って整列するように配置されました。
フレックススタート
この値をプロパティalign-itemsに渡すと、フレックスアイテムはコンテナの上部に垂直に配置されました。
次の例は、値 flex-start を align-items プロパティに渡した結果を示しています。
<!doctype html>
<html lang = "en">
<style>
.box1{background:green;}
.box2{background:blue;}
.box3{background:red;}
.box4{background:magenta;}
.box5{background:yellow;}
.box6{background:pink;}
.box{
font-size:35px;
padding:15px;
}
.container{
display:flex;
height:100vh;
align-items:flex-start;
}
</style>
<body>
<div class = "container">
<div class = "box box1">One</div>
<div class = "box box2">two</div>
<div class = "box box3">three</div>
<div class = "box box4">four</div>
<div class = "box box5">five</div>
<div class = "box box6">six</div>
</div>
</body>
</html>
それは次の結果を生成します-
フレックスエンド
この値をプロパティ align-items に渡すと、フレックスアイテムはコンテナの下部に垂直に配置されます。
次の例は、値 flex-end を align-items プロパティに渡した結果を示しています。
<!doctype html>
<html lang = "en">
<style>
.box1{background:green;}
.box2{background:blue;}
.box3{background:red;}
.box4{background:magenta;}
.box5{background:yellow;}
.box6{background:pink;}
.box{
font-size:35px;
padding:15px;
}
.container{
display:flex;
height:100vh;
align-items:flex-end;
}
</style>
<body>
<div class = "container">
<div class = "box box1">One</div>
<div class = "box box2">two</div>
<div class = "box box3">three</div>
<div class = "box box4">four</div>
<div class = "box box5">five</div>
<div class = "box box6">six</div>
</div>
</body>
</html>
それは次の結果を生成します-
センター
この値をプロパティ align-items に渡すと、flex-itemsはコンテナの中央に垂直に配置されます。
次の例は、値 flex-center を align-items プロパティに渡した結果を示しています。
<!doctype html>
<html lang = "en">
<style>
.box1{background:green;}
.box2{background:blue;}
.box3{background:red;}
.box4{background:magenta;}
.box5{background:yellow;}
.box6{background:pink;}
.box{
font-size:35px;
padding:15px;
}
.container{
display:flex;
height:100vh;
align-items:center;
}
</style>
<body>
<div class = "container">
<div class = "box box1">One</div>
<div class = "box box2">two</div>
<div class = "box box3">three</div>
<div class = "box box4">four</div>
<div class = "box box5">five</div>
<div class = "box box6">six</div>
</div>
</body>
</html>
それは次の結果を生成します-
ストレッチ
この値をプロパティ align-items に渡すと、flex-itemsは垂直方向に整列され、コンテナの垂直方向のスペース全体を埋めます。
次の例は、値 stretch を align-items プロパティに渡した結果を示しています。
<!doctype html>
<html lang = "en">
<style>
.box1{background:green;}
.box2{background:blue;}
.box3{background:red;}
.box4{background:magenta;}
.box5{background:yellow;}
.box6{background:pink;}
.box{
font-size:35px;
padding:15px;
}
.container{
display:flex;
height:100vh;
align-items:stretch;
}
</style>
<body>
<div class = "container">
<div class = "box box1">One</div>
<div class = "box box2">two</div>
<div class = "box box3">three</div>
<div class = "box box4">four</div>
<div class = "box box5">five</div>
<div class = "box box6">six</div>
</div>
</body>
</html>
それは次の結果を生成します-
ベースライン
この値をプロパティ align-items に渡すと、テキストのベースラインが水平線に沿って整列するようにflex-itemsが整列されます。
次の例は、値 baseline を align-items プロパティに渡した結果を示しています。
<!doctype html>
<html lang = "en">
<style>
.box1{background:green;}
.box2{background:blue;}
.box3{background:red;}
.box4{background:magenta;}
.box5{background:yellow;}
.box6{background:pink;}
.box{
font-size:35px;
padding:15px;
}
.container{
display:flex;
height:100vh;
align-items:baseline;
}
</style>
<body>
<div class = "container">
<div class = "box box1">One</div>
<div class = "box box2">two</div>
<div class = "box box3">three</div>
<div class = "box box4">four</div>
<div class = "box box5">five</div>
<div class = "box box6">six</div>
</div>
</body>
</html>
それは次の結果を生成します-