Flexbox 與 Grid
自身對齊方式justify-self
Controlling how an individual item is aligned along its inline axis.
Overview
| Class | Declarations |
|---|---|
justify-self:auto | justify-self: auto;
|
justify-self:normal | justify-self: normal;
|
justify-self:baseline | justify-self: baseline;
|
justify-self:left | justify-self: left;
|
justify-self:center | justify-self: center;
|
justify-self:right | justify-self: right;
|
justify-self:stretch | justify-self: stretch;
|
justify-self:start | justify-self: start;
|
justify-self:end | justify-self: end;
|
justify-self:flex-start | justify-self: flex-start;
|
justify-self:flex-end | justify-self: flex-end;
|
justify-self:self-start | justify-self: self-start;
|
justify-self:self-end | justify-self: self-end;
|
justify-self:<value> | justify-self: <value>;
|
Examples
Align one grid item inline
Use justify-self:* to override inline-axis alignment for a single grid item.
<div class="grid"> <button class="justify-self:end">Save</button></div>Generated CSS
@layer utilities { .grid { display: grid } .justify-self\:end { justify-self: end }}Center an item inside its area
Use justify-self:center when the grid area is wider than the item.
<img class="justify-self:center" src="..." alt="" />Use justify-items when every child should share the same inline alignment.
Apply conditionally
Apply styles based on different states using selectors and conditional queries.
<div class="justify-self:stretch justify-self:end@sm justify-self:stretch@print">...</div>For cross-axis item overrides, use align-self.