2017-11-06 19:22:02 +08:00
< style >
.demo-layout {
.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 >
## Layout
2017-11-11 15:32:35 +08:00
Rápido y facilmente crea un layout básico con 24 columnas.
2017-11-06 19:22:02 +08:00
2017-11-11 15:32:35 +08:00
### Layout básico
2017-11-06 19:22:02 +08:00
2017-11-11 15:32:35 +08:00
Crea un layout básico usando columnas.
2017-11-06 19:22:02 +08:00
2017-12-12 12:45:09 +08:00
:::demo Con `row` y `col` , puede facilmente manipular el layout usando el atributo `span` .
2017-11-06 19:22:02 +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 >
```
:::
2017-11-11 15:32:35 +08:00
### Espaciado de columnas
2017-11-06 19:22:02 +08:00
2017-11-11 15:32:35 +08:00
El espaciado de columnas está soportado.
2017-11-06 19:22:02 +08:00
2017-12-12 12:45:09 +08:00
:::demo Row provee el atributo `gutter` para especificar el espacio entre columnas y su valor por defecto es 0.
2017-11-06 19:22:02 +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 >
```
:::
2017-11-11 15:32:35 +08:00
### Layout híbrido
2017-11-06 19:22:02 +08:00
2017-11-11 15:32:35 +08:00
Crea un complejo layout híbrido combinando el básico de 1/24 columnas.
2017-11-06 19:22:02 +08:00
2017-12-12 12:45:09 +08:00
:::demo
2017-11-06 19:22:02 +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 >
```
:::
2017-11-11 15:32:35 +08:00
### Offset de columnas
2017-11-06 19:22:02 +08:00
2017-11-11 15:32:35 +08:00
Puedes especificar offsets para las columnas.
2017-11-06 19:22:02 +08:00
2017-12-12 12:45:09 +08:00
:::demo Puedes especificar el offset para una columna mediante el atributo `offset` de Col.
2017-11-06 19:22:02 +08:00
```html
< el-row :gutter = "20" >
< el-col :span = "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 >
< / el-row >
< el-row :gutter = "20" >
< 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 >
< / el-row >
< el-row :gutter = "20" >
< el-col :span = "12" :offset = "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 >
```
:::
2017-11-11 15:32:35 +08:00
### Alineación
2017-11-06 19:22:02 +08:00
2017-11-11 15:32:35 +08:00
Usa flex layout para un alineamiento flexible de columnas.
2017-11-06 19:22:02 +08:00
2017-12-12 12:45:09 +08:00
:::demo Puede habilitar flex layout asignando el atributo `type` a 'flex', y definir el layout de elementos hijos asignando el atributo `justify` con los valores start, center, end, space-between o space-around.
2017-11-06 19:22:02 +08:00
```html
< el-row type = "flex" class = "row-bg" >
< 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 >
< el-row type = "flex" class = "row-bg" justify = "center" >
< 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 >
< el-row type = "flex" class = "row-bg" justify = "end" >
< 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 >
< el-row type = "flex" class = "row-bg" justify = "space-between" >
< 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 >
< el-row type = "flex" class = "row-bg" justify = "space-around" >
< 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 >
```
:::
### Responsive Layout
2017-11-11 15:32:35 +08:00
Tomando el ejemplo de Bootstrap responsive design, existen 5 breakpoints: xs, sm, md, lg y xl.
2017-11-06 19:22:02 +08:00
2017-12-12 12:45:09 +08:00
:::demo
2017-11-06 19:22:02 +08:00
```html
< el-row :gutter = "10" >
< 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 >
< / 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 >
```
:::
2017-11-11 15:32:35 +08:00
### Clases útiles para ocultar elementos
2017-11-06 19:22:02 +08:00
2017-12-03 18:03:06 +08:00
Adicionalmente, Element 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:
2017-11-06 19:22:02 +08:00
```js
import 'element-ui/lib/theme-chalk/display.css';
```
2017-11-11 15:32:35 +08:00
Las clases son:
2017-12-03 18:03:06 +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
- `hidden-sm-and-up` - oculto en viewports pequeños y superiores
2017-11-11 15:32:35 +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
- `hidden-lg-only` - ocultos en viewports grandes solamente
- `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
### Atributos Row
2017-11-11 15:40:06 +08:00
2017-12-03 18:03:06 +08:00
| Atributos | Descripción | Tipo | Valores aceptados | Valor por defecto |
| --------- | ---------------------------------------- | ------ | ---------------------------------------- | ----------------- |
| gutter | espaciado de la grilla | number | — | 0 |
| type | modo del layout , puedes usar flex, funciona en navegadores modernos | string | — | — |
| 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 |
2017-11-06 19:22:02 +08:00
2017-11-11 15:32:35 +08:00
### Atributos Col
2017-11-11 15:40:06 +08:00
2017-12-03 18:03:06 +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}) | — | — |
| 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}) | — | — |
| tag | tag de elemento propio | string | * | div |
2017-11-06 19:22:02 +08:00