place-self プロパティ
プロパティ place-self は、
グリッド内の個別アイテムの配置を、
垂直軸と水平軸の両方に対して一度に設定します。
プロパティの値では、最初の項目が垂直方向の配置、
2番目が水平方向の配置を指定します。
このプロパティは、配置したいアイテム自体に設定します。
構文
アイテム {
place-self: 垂直方向の値 水平方向の値;
}
例 . 垂直方向中央、水平方向開始位置への配置
<div id="parent">
<div id="elem1">1</div>
<div>2</div>
<div>3</div>
<div>4</div>
</div>
#parent {
display: grid;
grid-template-columns: 100px 100px;
grid-template-rows: repeat(3, 1fr);
gap: 10px;
padding: 10px;
border: 2px solid #696989;
height: 200px;
width: 400px;
}
#parent > div {
gap: 10px;
padding: 10px;
box-sizing: border-box;
border: 1px solid #696989;
}
#elem1 {
place-self: center start;
}
:
例 . 垂直方向開始位置、水平方向終了位置への配置
<div id="parent">
<div id="elem1">1</div>
<div>2</div>
<div>3</div>
<div>4</div>
</div>
#parent {
display: grid;
grid-template-columns: 100px 100px;
grid-template-rows: repeat(3, 1fr);
gap: 10px;
padding: 10px;
border: 2px solid #696989;
height: 200px;
width: 400px;
}
#parent > div {
gap: 10px;
padding: 10px;
box-sizing: border-box;
border: 1px solid #696989;
}
#elem1 {
place-self: start end;
}
:
例 . 垂直方向終了位置、水平方向中央への配置
<div id="parent">
<div id="elem1">1</div>
<div>2</div>
<div>3</div>
<div>4</div>
</div>
#parent {
display: grid;
grid-template-columns: 100px 100px;
grid-template-rows: repeat(3, 1fr);
gap: 10px;
padding: 10px;
border: 2px solid #696989;
height: 200px;
width: 400px;
}
#parent > div {
gap: 10px;
padding: 10px;
box-sizing: border-box;
border: 1px solid #696989;
}
#elem1 {
place-self: end center;
}
:
関連項目
-
プロパティ
justify-self,
これはグリッド内の個別アイテムの水平方向の配置を設定します -
プロパティ
align-self,
これは単一のブロックの配置を設定します