123 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
		
		
			
		
	
	
			123 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
|   | --- | ||
|  | id: 5a90373638fddaf9a66b5d39 | ||
|  | title: Usa grid-row para controlar espaciado | ||
|  | challengeType: 0 | ||
|  | videoUrl: 'https://scrimba.com/p/pByETK/c9WBLU4' | ||
|  | forumTopicId: 301137 | ||
|  | dashedName: use-grid-row-to-control-spacing | ||
|  | --- | ||
|  | 
 | ||
|  | # --description--
 | ||
|  | 
 | ||
|  | Por supuesto, puedes hacer que los elementos ocupen múltiples filas así como se puede hacer con las columnas. Puedes definir las líneas horizontales donde quieres que un elemento empiece y termine usando la propiedad `grid-row` sobre un elemento de cuadrícula (grid). | ||
|  | 
 | ||
|  | # --instructions--
 | ||
|  | 
 | ||
|  | Haz que el elemento con clase `item5` ocupe las últimas dos filas. | ||
|  | 
 | ||
|  | # --hints--
 | ||
|  | 
 | ||
|  | La clase `item5` debe tener una propiedad `grid-row`. | ||
|  | 
 | ||
|  | ```js | ||
|  | assert( | ||
|  |   __helpers.removeWhiteSpace($('style').text()).match(/\.item5{.*grid-row:.*}/g) | ||
|  | ); | ||
|  | ``` | ||
|  | 
 | ||
|  | La clase `item5` debe tener una propiedad `grid-row` que resulta en ocupar las dos últimas filas de la cuadrícula. | ||
|  | 
 | ||
|  | ```js | ||
|  | const rowStart = getComputedStyle($('.item5')[0]).gridRowStart; | ||
|  | const rowEnd = getComputedStyle($('.item5')[0]).gridRowEnd; | ||
|  | const result = rowStart.toString() + rowEnd.toString(); | ||
|  | const correctResults = [ | ||
|  |   '24', | ||
|  |   '2-1', | ||
|  |   '2span 2', | ||
|  |   '2span2', | ||
|  |   'span 2-1', | ||
|  |   '-12', | ||
|  |   'span 2span 2', | ||
|  |   'span 2auto', | ||
|  |   'autospan 2' | ||
|  | ]; | ||
|  | assert(correctResults.includes(result)); | ||
|  | ``` | ||
|  | 
 | ||
|  | # --seed--
 | ||
|  | 
 | ||
|  | ## --seed-contents--
 | ||
|  | 
 | ||
|  | ```html | ||
|  | <style> | ||
|  |   .item1{background:LightSkyBlue;} | ||
|  |   .item2{background:LightSalmon;} | ||
|  |   .item3{background:PaleTurquoise;} | ||
|  |   .item4{background:LightPink;} | ||
|  | 
 | ||
|  |   .item5 { | ||
|  |     background: PaleGreen; | ||
|  |     grid-column: 2 / 4; | ||
|  |     /* Only change code below this line */ | ||
|  | 
 | ||
|  |     /* Only change code above this line */ | ||
|  |   } | ||
|  | 
 | ||
|  |   .container { | ||
|  |     font-size: 40px; | ||
|  |     min-height: 300px; | ||
|  |     width: 100%; | ||
|  |     background: LightGray; | ||
|  |     display: grid; | ||
|  |     grid-template-columns: 1fr 1fr 1fr; | ||
|  |     grid-template-rows: 1fr 1fr 1fr; | ||
|  |     grid-gap: 10px; | ||
|  |   } | ||
|  | </style> | ||
|  | 
 | ||
|  | <div class="container"> | ||
|  |   <div class="item1">1</div> | ||
|  |   <div class="item2">2</div> | ||
|  |   <div class="item3">3</div> | ||
|  |   <div class="item4">4</div> | ||
|  |   <div class="item5">5</div> | ||
|  | </div> | ||
|  | ``` | ||
|  | 
 | ||
|  | # --solutions--
 | ||
|  | 
 | ||
|  | ```html | ||
|  | <style> | ||
|  |   .item1{background:LightSkyBlue;} | ||
|  |   .item2{background:LightSalmon;} | ||
|  |   .item3{background:PaleTurquoise;} | ||
|  |   .item4{background:LightPink;} | ||
|  | 
 | ||
|  |   .item5 { | ||
|  |     background: PaleGreen; | ||
|  |     grid-column: 2 / 4; | ||
|  |     grid-row: 2 / 4; | ||
|  |   } | ||
|  | 
 | ||
|  |   .container { | ||
|  |     font-size: 40px; | ||
|  |     min-height: 300px; | ||
|  |     width: 100%; | ||
|  |     background: LightGray; | ||
|  |     display: grid; | ||
|  |     grid-template-columns: 1fr 1fr 1fr; | ||
|  |     grid-template-rows: 1fr 1fr 1fr; | ||
|  |     grid-gap: 10px; | ||
|  |   } | ||
|  | </style> | ||
|  | 
 | ||
|  | <div class="container"> | ||
|  |   <div class="item1">1</div> | ||
|  |   <div class="item2">2</div> | ||
|  |   <div class="item3">3</div> | ||
|  |   <div class="item4">4</div> | ||
|  |   <div class="item5">5</div> | ||
|  | </div> | ||
|  | ``` |