Propiedad flexible de estilo
Ejemplo
Deje que todos los elementos flexibles tengan la misma longitud, independientemente de su contenido:
for (i = 0; i
y[i].style.flex = "1";
}
Definición y uso
La propiedad flex establece o devuelve la longitud del elemento, en relación con el resto de elementos flexibles dentro del mismo contenedor.
La propiedad flex es una abreviatura de las propiedades flexGrow, flexShrink y flexBasis.
Nota: si el elemento no es un elemento flexible, la propiedad flex no tiene efecto.
Compatibilidad con navegador
Property | |||||
---|---|---|---|---|---|
flex | Yes | 11.0 10.0 msFlex |
Yes | 9.0 | Yes |
Sintaxis
Devuelve la propiedad flex:
object.style.flex
Establezca la propiedad flexible:
object.style.flex = "flex-grow flex-shrink flex-basis|auto|initial|inherit"
Valores de propiedad
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 |
Detalles técnicos
Valor por defecto: | 0 1 automático |
---|---|
Valor de retorno: | Una cadena, que representa la propiedad flexible de un elemento. |
Versión CSS | CSS3 |
páginas relacionadas
Referencia CSS: propiedad flexible
HTML DOM STYLE Referencia: propiedad flexBasis
Referencia HTML DOM STYLE: propiedad flexDirection
HTML DOM STYLE Referencia: propiedad flexFlow
Referencia HTML DOM STYLE: propiedad flexGrow
Referencia HTML DOM STYLE: propiedad flexShrink
HTML DOM STYLE Referencia: propiedad flexWrap
❮ Objeto de estilo