トップページ  > CSS  > place-self

★CSSリファレンス

place-self …… コンテナ内の個別アイテムの縦方向と横方向の揃え位置をまとめて指定する
Google Chrome Safari Firefox Opera
広告

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。
広告
Sponsors
広告
MuuMuu Domain!
ドメイン取るならお名前.com
現役エンジニアのオンライン家庭教師【CodeCamp】
サイトに広告を掲載してお小遣いが稼げる!【A8.net】
Node.jsコース
はじめてのプログラミングコース
▲ページ先頭へ
HTMLクイックリファレンスについて
© HTMQ