place-self …… コンテナ内の個別アイテムの縦方向と横方向の揃え位置をまとめて指定する
広告
place-selfプロパティは、コンテナ内の個別アイテムの縦方向と横方向の揃え位置をまとめて指定する際に使用します。
2つの値を半角スペース区切りで指定すると、
1番目はalign-selfプロパティの値、2番目はjustify-selfプロパティの値となります。
2番目の値を省略すると、1番目の値と同じとなります。
■値
- align-selfの値
- align-selfプロパティのページを参照
- justify-selfの値
- justify-selfプロパティのページを参照
■初期値・適用対象・値の継承
- 初期値
- auto
- 適用対象
- ブロックレベルボックス、絶対配置されたボックス、グリッドアイテム
- 値の継承
- しない
■使用例
CSSソース
.sample { display:grid; grid-template-columns:auto 1fr auto; grid-template-rows:50px; width:300px; background-color:white; border:1px solid black; } .hidari {grid-column:1; background-color:yellow;} .naka {grid-column:2; background-color: orange;} .migi {grid-column:3; background-color:pink;}
HTMLソース
<h5>中ボックスにplace-self:flex-start center;を指定。左50px・中50px・右50px。</h5> <div class="sample"> <div class="hidari" style="width:50px;">左</div> <div class="naka" style="width:50px; place-self:flex-start center;">中</div> <div class="migi" style="width:50px;">右</div> </div> <h5>中ボックスにplace-self:center center;を指定。左50px・中50px・右100px。</h5> <div class="sample"> <div class="hidari" style="width:50px;">左</div> <div class="naka" style="width:50px; place-self:center center;">中</div> <div class="migi" style="width:100px;">右</div> </div> <h5>中ボックスにplace-self:flex-end center;を指定。左50px・中50px・右150px。</h5> <div class="sample"> <div class="hidari" style="width:50px;">左</div> <div class="naka" style="width:50px; place-self:flex-end center;">中</div> <div class="migi" style="width:150px;">右</div> </div>
↓↓↓
ブラウザ上の表示
中ボックスにplace-self:flex-start center;を指定。左50px・中50px・右50px。
左
中
右
中ボックスにplace-self:center center;を指定。左50px・中50px・右100px。
左
中
右
中ボックスにplace-self:flex-end center;を指定。左50px・中50px・右150px。
左
中
右
広告