CSS place-content egenskab
- Forrige side perspective-origin
- Næste side place-items
Definition og brug
place-content
Egenskaber bruges til fleksible boks (flexbox) og raster (grid) layout og er kortform for følgende egenskaber:
Hvis place-content attributten har to værdier:
place-content: start center;
- Værdien for align-content attributten er 'start'
- Værdien for justify-content attributten er 'center'
Hvis place-content attributten kun har én værdi:
place-content: end;
- Derved er værdierne for align-content og justify-content attributterne begge 'end'
Eksempel
Eksempel 1
Specificer fleksibilitet i bunden af fleksible beholder og jævne afstande mellem fleksible elementer i lodret retning:
#container { display: flex; place-content: end space-between; }
Example 2: Grid Layout
Extra space in the block direction is evenly distributed around each grid item, and the grid items are centered in the inline direction:
#container { display: grid; place-content: space-around center; }
CSS Syntax
place-content: normal|value|initial|inherit;
Property Value
Value | Description |
---|---|
normal |
Default Value. Depends on the layout context. Is equivalent to not setting properties for align-content and justify-content. |
stretch |
Grid: If the size is not set, the grid item will stretch to fill the grid container. Flexbox: If the flex item does not specify a size on the cross axis, it will stretch on the cross axis to fill the flex container. |
start | Aligns items to the start position of the container. |
end | Aligns items to the end position of the container. |
center | Aligns items to the center position of the container. |
space-between | Distributes available space evenly along the two axes of the container, making the spacing between items equal. |
space-around | Distributes available space evenly along the two axes of the container, making the spacing around each item equal. |
space-evenly | Distributes items evenly along the two axes of the container. |
overflow-alignment |
'safe': If the content overflows, the item alignment is set to 'start'. 'unsafe': The alignment value is kept unchanged regardless of whether the content of the item overflows. |
initial | Sets this property to its default value. See: initial. |
inherit | Inherits this property from its parent element. See: inherit. |
Technical Details
Default Value: | normal |
---|---|
Inheritance: | No |
Animation Creation: | Not supported. See:Animation-related Properties. |
Version: | CSS3 |
JavaScript Syntax: | object.style.placeContent="end space-around" |
Browser Support
The numbers in the table represent the first browser version to fully support this property.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
59.0 | 79.0 | 53.0 | 11.0 | 46.0 |
Related Pages
Tutorial:CSS Grid Layout
Tutorial:CSS Flexbox Layout
Reference:CSS align-content property
Reference:CSS justify-content egenskab
Reference:HTML DOM alignContent egenskab
- Forrige side perspective-origin
- Næste side place-items