Propriedade CSS justifique-conteúdo
Exemplo
Alinhe os itens flexíveis no centro do contêiner:
div
{
display: flex;
justify-content: center;
}
Mais exemplos de "Experimente você mesmo" abaixo.
Definição e uso
A justify-content
propriedade alinha os itens do container flexível quando os itens não utilizam todo o espaço disponível no eixo principal (horizontal).
Dica: Use a propriedade align-items para alinhar os itens verticalmente.
Valor padrão: | início flexível |
---|---|
Herdado: | não |
Animavel: | não. Leia sobre animáveis |
Versão: | CSS3 |
Sintaxe JavaScript: | objeto .style.justifyContent="espaço-entre" |
Suporte ao navegador
Os números na tabela especificam a primeira versão do navegador que oferece suporte total à propriedade.
Números seguidos por -webkit- ou -moz- especificam a primeira versão que funcionou com um prefixo.
Property | |||||
---|---|---|---|---|---|
justify-content | 29.0 21.0 -webkit- |
11.0 | 28.0 18.0 -moz- |
9.0 6.1 -webkit- |
17.0 |
Sintaxe CSS
justify-content: flex-start|flex-end|center|space-between|space-around|space-evenly|initial|inherit;
Valores de propriedade
Value | Description | Play it |
---|---|---|
flex-start | Default value. Items are positioned at the beginning of the container | |
flex-end | Items are positioned at the end of the container | |
center | Items are positioned in the center of the container | |
space-between | Items will have space between them | |
space-around | Items will have space before, between, and after them | |
space-evenly | Items will have equal space around them | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
Mais exemplos
Exemplo
Alinhe os itens flexíveis no início do contêiner (este é o padrão):
div
{
display: flex;
justify-content: flex-start;
}
Exemplo
Alinhe os itens flexíveis no final do contêiner:
div
{
display: flex;
justify-content: flex-end;
}
Exemplo
Exiba os itens flexíveis com espaço entre as linhas:
div
{
display: flex;
justify-content: space-between;
}
Exemplo
Exiba os itens flexíveis com espaço antes, entre e depois das linhas:
div
{
display: flex;
justify-content: space-around;
}
Páginas relacionadas
Referência CSS: propriedade align-content
Referência CSS: propriedade align-items
Referência CSS: propriedade align-self
Referência HTML DOM: propriedade justifyContent