| 
									
										
										
										
											2018-10-10 18:03:03 -04:00
										 |  |  | --- | 
					
						
							|  |  |  | id: 587d78ac367417b2b2512af4 | 
					
						
							| 
									
										
										
										
											2020-12-16 00:37:30 -07:00
										 |  |  | title: 使用 flex-direction 属性创建一列 | 
					
						
							| 
									
										
										
										
											2018-10-10 18:03:03 -04:00
										 |  |  | challengeType: 0 | 
					
						
							| 
									
										
										
										
											2020-02-11 21:32:25 +08:00
										 |  |  | videoUrl: 'https://scrimba.com/p/pVaDAv/cZmWeA4' | 
					
						
							|  |  |  | forumTopicId: 301109 | 
					
						
							| 
									
										
										
										
											2021-01-13 03:31:00 +01:00
										 |  |  | dashedName: use-the-flex-direction-property-to-make-a-column | 
					
						
							| 
									
										
										
										
											2018-10-10 18:03:03 -04:00
										 |  |  | --- | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-16 00:37:30 -07:00
										 |  |  | # --description--
 | 
					
						
							| 
									
										
										
										
											2018-10-10 18:03:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-06 04:42:36 +00:00
										 |  |  | 在之前两个挑战中,我们使用了 `flex-direction` 属性,值为 `row`。 这个属性还能创建一个列,让子元素竖直排列在 flex 容器中。 | 
					
						
							| 
									
										
										
										
											2018-10-10 18:03:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-16 00:37:30 -07:00
										 |  |  | # --instructions--
 | 
					
						
							| 
									
										
										
										
											2018-10-10 18:03:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-08 11:20:48 -08:00
										 |  |  | 请给 `#box-container` 元素添加 CSS 属性 `flex-direction`,并将其属性值设置为 `column`。 | 
					
						
							| 
									
										
										
										
											2018-10-10 18:03:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-16 00:37:30 -07:00
										 |  |  | # --hints--
 | 
					
						
							| 
									
										
										
										
											2018-10-10 18:03:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-08 11:20:48 -08:00
										 |  |  | `#box-container` 应有 `flex-direction` 属性,其属性值应为 `column`。 | 
					
						
							| 
									
										
										
										
											2018-10-10 18:03:03 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-16 00:37:30 -07:00
										 |  |  | ```js | 
					
						
							|  |  |  | assert($('#box-container').css('flex-direction') == 'column'); | 
					
						
							| 
									
										
										
										
											2018-10-10 18:03:03 -04:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-13 03:31:00 +01:00
										 |  |  | # --seed--
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## --seed-contents--
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```html | 
					
						
							|  |  |  | <style> | 
					
						
							|  |  |  |   #box-container { | 
					
						
							|  |  |  |     display: flex; | 
					
						
							|  |  |  |     height: 500px; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   #box-1 { | 
					
						
							|  |  |  |     background-color: dodgerblue; | 
					
						
							|  |  |  |     width: 50%; | 
					
						
							|  |  |  |     height: 50%; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   #box-2 { | 
					
						
							|  |  |  |     background-color: orangered; | 
					
						
							|  |  |  |     width: 50%; | 
					
						
							|  |  |  |     height: 50%; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | </style> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <div id="box-container"> | 
					
						
							|  |  |  |   <div id="box-1"></div> | 
					
						
							|  |  |  |   <div id="box-2"></div> | 
					
						
							|  |  |  | </div> | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-16 00:37:30 -07:00
										 |  |  | # --solutions--
 | 
					
						
							| 
									
										
										
										
											2020-02-11 21:32:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-13 03:31:00 +01:00
										 |  |  | ```html | 
					
						
							|  |  |  | <style> | 
					
						
							|  |  |  |   #box-container { | 
					
						
							|  |  |  |     display: flex; | 
					
						
							|  |  |  |     height: 500px; | 
					
						
							|  |  |  |     flex-direction: column; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   #box-1 { | 
					
						
							|  |  |  |     background-color: dodgerblue; | 
					
						
							|  |  |  |     width: 50%; | 
					
						
							|  |  |  |     height: 50%; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   #box-2 { | 
					
						
							|  |  |  |     background-color: orangered; | 
					
						
							|  |  |  |     width: 50%; | 
					
						
							|  |  |  |     height: 50%; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | </style> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <div id="box-container"> | 
					
						
							|  |  |  |   <div id="box-1"></div> | 
					
						
							|  |  |  |   <div id="box-2"></div> | 
					
						
							|  |  |  | </div> | 
					
						
							|  |  |  | ``` |