Skip to content

Commit baf8373

Browse files
author
Cristina Fernández Sanz
committed
Item properties explanation
1 parent a879412 commit baf8373

File tree

29 files changed

+4122
-0
lines changed

29 files changed

+4122
-0
lines changed

README.md

+214
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,220 @@ The first 3 exercises were exported as zip from my [Codepen collection](https://
112112
113113
- [Demo](https://cristinafsanz.github.io/css-flexbox-gridlayout/flexbox/6.exercise-4-with-flexbox-header-with-menu/index.html)
114114
115+
### Item properties
116+
117+
[Class: Item properties](https://escuela.it/cursos/taller-profesional-flexbox/clase/practica-y-ejemplos-ii)
118+
119+
- Cross size: Eje secundario / Cross axis
120+
- Si se ha definido (por width o por height), ese tamaño se respetará.
121+
- Si no se ha definido, se utilizará todo el espacio disponible (STRETCH).
122+
- Si no se ha definido y se utiliza un valor diferente de stretch para align-content o align-items en el contenedor, se tomará el tamaño de su contenido.
123+
124+
- Main size: Eje principal / Main axis
125+
- Si no se ha definido el tamaño, se calculará según el contenido.
126+
- si se ha definido (por width o height) éste podría respetarse, podría encogerse o crecer. // hace caso o no!
127+
- Si no hay espacio suficiente, por defecto los items encogen para caber dentro del contenedor.
128+
- Si hay espacio suficiente, por defecto no crecen, porque Flexbox quiere que le digamos cómo queremos que crezcan.
129+
130+
- Flex-basis: Tamaño base que se considera para los cálculos, no el tamaño definitivo.
131+
- Siempre gana a width o height.
132+
- No siempre controla el ancho, en flex-direction: column, flex-basis controla el alto.
133+
- Sólo funciona sobre el main-axis.
134+
- Flex-basis gana: si utilizo la propiedad Flex que es el shorhand de flex-grow, flex-shrink, flex-basis sobreescribiré el width sin darme cuenta.
135+
- En responsive es fácil que pase de flex-direction: row a column, si establezco width tendré problemas.
136+
137+
- Flex-grow (crecimiento)
138+
- Controla cuánto crece un elemento para rellenar el espacio sobrante.
139+
- Sólo se aplica si hay espacio disponible.
140+
- Es un número positivo -> unidades que crecerá.
141+
- Unidad = Espacio disponible / suma de flex-grows en la misma línea.
142+
- Que se coja el doble de hueco por ej. al usar flex-grow: 2 / flex-grow: 1. No es que una sea el doble del otro.
143+
- Por defecto flex-grow: 0 // no crece
144+
145+
- Flex-shrink (estrechamiento)
146+
- Si el espacio disponible es negativo (el tamaño del contenedor es menor a la suma de los tamaños de los items), por defecto los items se encogen en proporciones iguales para caber en una sola línea, pero respetando el contenido o si tiene establecido min-width o min-height.
147+
- Unidad = Espacio disponible (será negativo) / suma de flex-shrink en la misma línea.
148+
- Por defecto flex-shrink: 1 // si lo necesita, encoger
149+
- flex-shrink: 0 // no encoge. El que más se utiliza.
150+
- flex-shrink: 3 // encogerá en mayor proporción si lo necesita (al tripe de velocidad)
151+
152+
### Exercise 5
153+
154+
![Exercise 5 image](images/flexbox/exercise-5.png?raw=true)
155+
156+
- [Code](flexbox/7.exercise-5-search-box)
157+
158+
```
159+
.input-wrapper {
160+
display: flex;
161+
}
162+
input {
163+
flex-grow: 1;
164+
}
165+
```
166+
167+
- [Demo](https://cristinafsanz.github.io/css-flexbox-gridlayout/flexbox/7.exercise-5-search-box/index.html)
168+
169+
### Exercise 6
170+
171+
![Exercise 6 image](images/flexbox/exercise-6.png?raw=true)
172+
173+
Si hay contenido mayor al alto hará scroll y el footer se mantiene abajo y si no lo hay también.
174+
175+
- [Code](flexbox/8.exercise-6-sticky-footer)
176+
177+
```
178+
.app {
179+
min-height: 100vh;
180+
display: flex;
181+
flex-direction: column;
182+
}
183+
main {
184+
flex-grow: 1;
185+
}
186+
```
187+
188+
- [Demo](https://cristinafsanz.github.io/css-flexbox-gridlayout/flexbox/8.exercise-6-sticky-footer/index.html)
189+
190+
### Exercise 7
191+
192+
![Exercise 7 image](images/flexbox/exercise-7.jpg?raw=true)
193+
194+
- [Code](flexbox/9.exercise-7-fixed-header-footer)
195+
196+
```
197+
.app {
198+
height: 100vh;
199+
display: flex;
200+
flex-direction: column;
201+
}
202+
main {
203+
flex-grow: 1;
204+
overflow: auto;
205+
}
206+
header,
207+
footer {
208+
height: 7rem;
209+
flex-shrink: 0;
210+
}
211+
```
212+
213+
- [Demo](https://cristinafsanz.github.io/css-flexbox-gridlayout/flexbox/9.exercise-7-fixed-header-footer/index.html)
214+
215+
### Exercise 8
216+
217+
Main no debería contener navs, footer...por semántica. Se va usar por eso un div.
218+
219+
![Exercise 8 image](images/flexbox/exercise-8.jpg?raw=true)
220+
221+
- [Code](flexbox/10.exercise-8-holy-grail-layout)
222+
223+
```
224+
.app {
225+
height: 100vh;
226+
display: flex;
227+
flex-direction: column;
228+
}
229+
header,
230+
footer {
231+
height: 7rem;
232+
flex-shrink: 0;
233+
}
234+
#main {
235+
flex-grow: 1;
236+
display: flex;
237+
}
238+
nav,
239+
aside {
240+
flex-basis: 15%;
241+
}
242+
article {
243+
flex-grow: 1;
244+
overflow: auto;
245+
}
246+
```
247+
248+
- [Demo](https://cristinafsanz.github.io/css-flexbox-gridlayout/flexbox/10.exercise-8-holy-grail-layout/index.html)
249+
250+
### Exercise 9
251+
252+
Mejor empezar con mobile (mobile first) aunque aquí se haga al revés.
253+
254+
![Exercise 9 image](images/flexbox/exercise-9.jpg?raw=true)
255+
256+
- [Code](flexbox/11.exercise-9-holy-grail-layout-responsive)
257+
258+
```
259+
@media screen and (max-width: 39em){
260+
#main {
261+
flex-direction: column;
262+
}
263+
nav {
264+
min-height: 4rem
265+
}
266+
}
267+
```
268+
269+
- [Demo](https://cristinafsanz.github.io/css-flexbox-gridlayout/flexbox/11.exercise-9-holy-grail-layout-responsive/index.html)
270+
271+
### Exercise 10
272+
273+
![Exercise 10 image](images/flexbox/exercise-10.png?raw=true)
274+
275+
- [Code](flexbox/12.exercise-10-list-items)
276+
277+
```
278+
.store {
279+
display: flex;
280+
}
281+
.circle {
282+
flex-shrink: 0;
283+
}
284+
.next {
285+
align-self: center;
286+
}
287+
.store-id {
288+
flex-basis: 20%;
289+
flex-shrink: 0;
290+
}
291+
.address-tpv {
292+
flex-grow: 1;
293+
}
294+
```
295+
296+
- [Demo](https://cristinafsanz.github.io/css-flexbox-gridlayout/flexbox/12.exercise-10-list-items/index.html)
297+
298+
### Exercise 11
299+
300+
![Exercise 11 image](images/flexbox/exercise-11.jpg?raw=true)
301+
302+
- [Code](flexbox/13.exercise-11-box-columns-inside)
303+
304+
```
305+
.row {
306+
display: flex;
307+
justify-content: space-between;
308+
}
309+
.info-box {
310+
flex-basis: 44%;
311+
display: flex;
312+
flex-direction: column;
313+
}
314+
.text-container {
315+
flex-grow: 1;
316+
}
317+
header {
318+
display: flex;
319+
}
320+
.title {
321+
flex-grow: 1;
322+
}
323+
```
324+
325+
- [Demo](https://cristinafsanz.github.io/css-flexbox-gridlayout/flexbox/13.exercise-11-box-columns-inside/index.html)
326+
327+
### TODO:
328+
Falta por hacer la [última clase](https://escuela.it/cursos/taller-profesional-flexbox/clase/practicas-y-ejemplos-iv) a partir de minuto 47.
115329
116330
## CSS Grid Layout
117331

0 commit comments

Comments
 (0)