Propriedade flexível de estilo
Exemplo
Deixe que todos os itens flexíveis tenham o mesmo comprimento, independentemente de seu conteúdo:
for (i = 0; i
y[i].style.flex = "1";
}
Definição e uso
A propriedade flex define ou retorna o comprimento do item, em relação ao restante dos itens flexíveis dentro do mesmo container.
A propriedade flex é um atalho para as propriedades flexGrow, flexShrink e flexBasis.
Nota: Se o elemento não for um item flexível, a propriedade flex não terá efeito.
Suporte ao navegador
Property | |||||
---|---|---|---|---|---|
flex | Yes | 11.0 10.0 msFlex |
Yes | 9.0 | Yes |
Sintaxe
Retorne a propriedade flex:
object.style.flex
Defina a propriedade flex:
object.style.flex = "flex-grow flex-shrink flex-basis|auto|initial|inherit"
Valores de propriedade
Value | Description |
---|---|
flex-grow | A number specifying how much the item will grow relative to the rest of the flexible items |
flex-shrink | A number specifying how much the item will shrink relative to the rest of the flexible items |
flex-basis | The length of the item. Legal values: "auto", "inherit", or a number followed by "%", "px", "em" or any other length unit |
auto | Same as 1 1 auto. |
initial | Same as 0 1 auto. Read about initial |
none | Same as 0 0 auto. |
inherit | Inherits this property from its parent element. Read about inherit |
Detalhes técnicos
Valor padrão: | 0 1 automático |
---|---|
Valor de retorno: | Uma String, representando a propriedade flex de um elemento |
Versão CSS | CSS3 |
Páginas relacionadas
Referência CSS: propriedade flex
Referência HTML DOM STYLE: propriedade flexBasis
Referência HTML DOM STYLE: propriedade flexDirection
Referência HTML DOM STYLE: propriedade flexFlow
Referência HTML DOM STYLE: propriedade flexGrow
Referência HTML DOM STYLE: propriedade flexShrink
Referência HTML DOM STYLE: propriedade flexWrap
❮ Objeto de estilo