CSS align-items property
Example
Center the alignments for all the items of the flexible <div> element:
div {
display: flex;
align-items: center;
}
display: flex;
align-items: center;
}
Definition and Usage
The align-items
property specifies the default alignment for items inside the flexible container.
It will align the flex-items inside the flex-container.
Tip: Use the align-self property of each item to override the align-items
property.
Default value: | stretch |
---|---|
Inherited: | no |
Animatable: | no. |
Version: | CSS3 |
JavaScript syntax: | object.style.alignItems="center" |
- Inherited : "Inherited = no" means that it cannot takes (inherit) it's value from it's parent element.
- object - object in javascript means the element on which
align-items
is applied. - Animatable - "Animatable = no" means that it cannot be animated with CSS
@keyframes
.
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Numbers followed by -webkit- specify the first version that worked with a prefix.
Property | |||||
---|---|---|---|---|---|
align-items | 21.0 | 11.0 | 20.0 | 9.0 7.0 -webkit- |
12.1 |
CSS Syntax
align-items: stretch|center|flex-start|flex-end|baseline|initial|inherit;
Property Values
Value | Description | Play it |
---|---|---|
stretch | Default. Items are stretched to fit the container | |
center | Items are positioned at the center of the container | |
flex-start | Items are positioned at the beginning of the container | |
flex-end | Items are positioned at the end of the container | |
baseline | Items are positioned at the baseline of the container | |
initial | Sets this property to its default value. | |
inherit | Inherits this property from its parent element. |
More Examples
Example
Items are positioned at the beginning of the container:
div {
display: flex;
align-items: flex-start;
}
display: flex;
align-items: flex-start;
}
Example
Items are positioned at the end of the container:
div {
display: flex;
align-items: flex-end;
}
display: flex;
align-items: flex-end;
}
Example
Items are positioned at the baseline of the container:
div {
display: flex;
align-items: baseline;
}
display: flex;
align-items: baseline;
}
Example
Items are stretched to fit the container:
div {
display: flex;
align-items: stretch;
}
display: flex;
align-items: stretch;
}
Comments
Post a Comment