2020-08-13 15:18:26 +08:00
## Layout
Rápido y facilmente crea un layout básico con 24 columnas.
2021-06-26 14:48:18 +08:00
:::tip
The component uses flex layout by default, no need to set `type="flex"` manually.
Please note that the parent container should avoid using `inline` related styles, which will cause the component to not fill up its width.
:::
2020-08-13 15:18:26 +08:00
### Layout básico
Crea un layout básico usando columnas.
:::demo Con `row` y `col` , puede facilmente manipular el layout usando el atributo `span` .
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
```html
< el-row >
< el-col :span = "24" > < div class = "grid-content bg-purple-dark" > < / div > < / el-col >
< / el-row >
< el-row >
< el-col :span = "12" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "12" > < div class = "grid-content bg-purple-light" > < / div > < / el-col >
< / el-row >
< el-row >
< el-col :span = "8" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "8" > < div class = "grid-content bg-purple-light" > < / div > < / el-col >
< el-col :span = "8" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< / el-row >
< el-row >
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple-light" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple-light" > < / div > < / el-col >
< / el-row >
< el-row >
< el-col :span = "4" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "4" > < div class = "grid-content bg-purple-light" > < / div > < / el-col >
< el-col :span = "4" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "4" > < div class = "grid-content bg-purple-light" > < / div > < / el-col >
< el-col :span = "4" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "4" > < div class = "grid-content bg-purple-light" > < / div > < / el-col >
< / el-row >
< style >
.el-row {
margin-bottom: 20px;
& :last-child {
margin-bottom: 0;
}
}
.el-col {
border-radius: 4px;
}
.bg-purple-dark {
background: #99a9bf ;
}
.bg-purple {
background: #d3dce6 ;
}
.bg-purple-light {
background: #e5e9f2 ;
}
.grid-content {
border-radius: 4px;
min-height: 36px;
}
.row-bg {
padding: 10px 0;
background-color: #f9fafc ;
}
< / style >
```
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
:::
### Espaciado de columnas
El espaciado de columnas está soportado.
:::demo Row provee el atributo `gutter` para especificar el espacio entre columnas y su valor por defecto es 0.
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
```html
< el-row :gutter = "20" >
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< / el-row >
< style >
.el-row {
margin-bottom: 20px;
& :last-child {
margin-bottom: 0;
}
}
.el-col {
border-radius: 4px;
}
.bg-purple-dark {
background: #99a9bf ;
}
.bg-purple {
background: #d3dce6 ;
}
.bg-purple-light {
background: #e5e9f2 ;
}
.grid-content {
border-radius: 4px;
min-height: 36px;
}
.row-bg {
padding: 10px 0;
background-color: #f9fafc ;
}
< / style >
```
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
:::
### Layout híbrido
Crea un complejo layout híbrido combinando el básico de 1/24 columnas.
:::demo
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
```html
< el-row :gutter = "20" >
< el-col :span = "16" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "8" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< / el-row >
< el-row :gutter = "20" >
< el-col :span = "8" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "8" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "4" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "4" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< / el-row >
< el-row :gutter = "20" >
< el-col :span = "4" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "16" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "4" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< / el-row >
< style >
.el-row {
margin-bottom: 20px;
& :last-child {
margin-bottom: 0;
}
}
.el-col {
border-radius: 4px;
}
.bg-purple-dark {
background: #99a9bf ;
}
.bg-purple {
background: #d3dce6 ;
}
.bg-purple-light {
background: #e5e9f2 ;
}
.grid-content {
border-radius: 4px;
min-height: 36px;
}
.row-bg {
padding: 10px 0;
background-color: #f9fafc ;
}
< / style >
```
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
:::
### Offset de columnas
Puedes especificar offsets para las columnas.
:::demo Puedes especificar el offset para una columna mediante el atributo `offset` de Col.
```html
< el-row :gutter = "20" >
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
2021-09-04 19:29:28 +08:00
< el-col :span = "6" :offset = "6"
>< div class = "grid-content bg-purple" > < /div
>< / el-col >
2020-08-13 15:18:26 +08:00
< / el-row >
< el-row :gutter = "20" >
2021-09-04 19:29:28 +08:00
< el-col :span = "6" :offset = "6"
>< div class = "grid-content bg-purple" > < /div
>< / el-col >
< el-col :span = "6" :offset = "6"
>< div class = "grid-content bg-purple" > < /div
>< / el-col >
2020-08-13 15:18:26 +08:00
< / el-row >
< el-row :gutter = "20" >
2021-09-04 19:29:28 +08:00
< el-col :span = "12" :offset = "6"
>< div class = "grid-content bg-purple" > < /div
>< / el-col >
2020-08-13 15:18:26 +08:00
< / el-row >
< style >
.el-row {
margin-bottom: 20px;
& :last-child {
margin-bottom: 0;
}
}
.el-col {
border-radius: 4px;
}
.bg-purple-dark {
background: #99a9bf ;
}
.bg-purple {
background: #d3dce6 ;
}
.bg-purple-light {
background: #e5e9f2 ;
}
.grid-content {
border-radius: 4px;
min-height: 36px;
}
.row-bg {
padding: 10px 0;
background-color: #f9fafc ;
}
< / style >
```
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
:::
### Alineación
2021-06-26 14:48:18 +08:00
Default use the flex layout to make flexible alignment of columns.
2020-08-13 15:18:26 +08:00
2021-06-26 14:48:18 +08:00
:::demo You can define the layout of child elements by setting `justify` attribute with start, center, end, space-between or space-around.
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
```html
2021-06-26 14:48:18 +08:00
< el-row class = "row-bg" >
2020-08-13 15:18:26 +08:00
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple-light" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< / el-row >
2021-06-26 14:48:18 +08:00
< el-row class = "row-bg" justify = "center" >
2020-08-13 15:18:26 +08:00
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple-light" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< / el-row >
2021-06-26 14:48:18 +08:00
< el-row class = "row-bg" justify = "end" >
2020-08-13 15:18:26 +08:00
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple-light" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< / el-row >
2021-06-26 14:48:18 +08:00
< el-row class = "row-bg" justify = "space-between" >
2020-08-13 15:18:26 +08:00
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple-light" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< / el-row >
2021-06-26 14:48:18 +08:00
< el-row class = "row-bg" justify = "space-around" >
2020-08-13 15:18:26 +08:00
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple-light" > < / div > < / el-col >
< el-col :span = "6" > < div class = "grid-content bg-purple" > < / div > < / el-col >
< / el-row >
< style >
.el-row {
margin-bottom: 20px;
& :last-child {
margin-bottom: 0;
}
}
.el-col {
border-radius: 4px;
}
.bg-purple-dark {
background: #99a9bf ;
}
.bg-purple {
background: #d3dce6 ;
}
.bg-purple-light {
background: #e5e9f2 ;
}
.grid-content {
border-radius: 4px;
min-height: 36px;
}
.row-bg {
padding: 10px 0;
background-color: #f9fafc ;
}
< / style >
```
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
:::
### Responsive Layout
Tomando el ejemplo de Bootstrap responsive design, existen 5 breakpoints: xs, sm, md, lg y xl.
:::demo
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
```html
< el-row :gutter = "10" >
2021-09-04 19:29:28 +08:00
< el-col :xs = "8" :sm = "6" :md = "4" :lg = "3" :xl = "1"
>< div class = "grid-content bg-purple" > < /div
>< / el-col >
< el-col :xs = "4" :sm = "6" :md = "8" :lg = "9" :xl = "11"
>< div class = "grid-content bg-purple-light" > < /div
>< / el-col >
< el-col :xs = "4" :sm = "6" :md = "8" :lg = "9" :xl = "11"
>< div class = "grid-content bg-purple" > < /div
>< / el-col >
< el-col :xs = "8" :sm = "6" :md = "4" :lg = "3" :xl = "1"
>< div class = "grid-content bg-purple-light" > < /div
>< / el-col >
2020-08-13 15:18:26 +08:00
< / el-row >
< style >
.el-col {
border-radius: 4px;
}
.bg-purple-dark {
background: #99a9bf ;
}
.bg-purple {
background: #d3dce6 ;
}
.bg-purple-light {
background: #e5e9f2 ;
}
.grid-content {
border-radius: 4px;
min-height: 36px;
}
< / style >
```
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
:::
### Clases útiles para ocultar elementos
2020-10-16 11:14:34 +08:00
Adicionalmente, Element Plus provee una serie de clases para ocultar elementos dadas ciertas condiciones. Estas clases pueden se agregadas a cualquier elemento del DOM o un elemento propio. Necesita importar el siguiente archivo CSS para usar estas clases:
2020-08-13 15:18:26 +08:00
```js
2021-09-04 19:29:28 +08:00
import 'element-plus/lib/theme-chalk/display.css'
2020-08-13 15:18:26 +08:00
```
Las clases son:
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
- `hidden-xs-only` - oculto en viewports extra pequeños solamente
- `hidden-sm-only` - oculto en viewports pequeños solamente
- `hidden-sm-and-down` - oculto en viewports pequeños y menores
2020-10-16 11:14:34 +08:00
- `hidden-sm-and-up` - oculto en viewports pequeños y superiores
2020-08-13 15:18:26 +08:00
- `hidden-md-only` - oculto en viewports medios solamente
- `hidden-md-and-down` - oculto en viewports medios y menores
- `hidden-md-and-up` - oculto en viewports medios y mayores
2020-10-16 11:14:34 +08:00
- `hidden-lg-only` - ocultos en viewports grandes solamente
2020-08-13 15:18:26 +08:00
- `hidden-lg-and-down` - ocultos en viewports grandes y menores
- `hidden-lg-and-up` - ocultos en viewports grandes y superiores
- `hidden-xl-only` - oculto en viewports extra grandes solamente
2020-10-16 11:14:34 +08:00
### Atributos Row
2020-08-13 15:18:26 +08:00
2021-09-04 19:29:28 +08:00
| Atributos | Descripción | Tipo | Valores aceptados | Valor por defecto |
| --------- | ------------------------------------- | ------ | ------------------------------------------- | ----------------- |
| gutter | espaciado de la grilla | number | — | 0 |
| justify | alineación horizontal del layout flex | string | start/end/center/space-around/space-between | start |
| align | alineación vertical del layout flex | string | top/middle/bottom | top |
| tag | tag de elemento propio | string | \* | div |
2020-08-13 15:18:26 +08:00
2020-10-16 11:14:34 +08:00
### Atributos Col
2020-08-13 15:18:26 +08:00
2021-09-04 19:29:28 +08:00
| Atributos | Descripción | Tipo | Valores aceptados | Valor por defecto |
| --------- | -------------------------------------------------------------------- | ----------------------------------------- | ----------------- | ----------------- |
| span | número de columnas que abarca la cuadrícula | number | — | 24 |
| offset | especific espacio en el lado izquierdo de la grill | number | — | 0 |
| push | número de columnas que la grilla se mueve hacia la derecha | number | — | 0 |
| pull | número de columnas que la grilla se mueve hacia la izquierda | number | — | 0 |
| xs | `<768px` Columnas responsive u objeto con propiedades de la columna | number/object (e.g. {span: 4, offset: 4}) | — | — |
| sm | `≥768px` Columnas responsive u objeto con propiedades de la columna | number/object (e.g. {span: 4, offset: 4}) | — | — |
| md | `≥992px` Columnas responsive u objeto con propiedades de la columna | number/object (e.g. {span: 4, offset: 4}) | — | — |
2020-08-13 15:18:26 +08:00
| lg | `≥1200px` Columnas responsive u objeto con propiedades de la columna | number/object (e.g. {span: 4, offset: 4}) | — | — |
| xl | `≥1920px` Columnas responsive u objeto con propiedades de la columna | number/object (e.g. {span: 4, offset: 4}) | — | — |
2021-09-04 19:29:28 +08:00
| tag | tag de elemento propio | string | \* | div |