---
id: 587d78ae367417b2b2512afd
title: Use the flex-basis Property to Set the Initial Size of an Item
challengeType: 0
videoUrl: 'https://scrimba.com/p/pVaDAv/c3d9nCa'
forumTopicId: 301108
localeTitle: 使用 flex-basis 属性设置项目的初始大小
---
## Description
flex-basis属性定义了在使用 CSS 的flex-shrink或flex-grow属性对项目进行调整前,项目的初始大小。
flex-basis属性的单位与其他表示尺寸的属性的单位一致(px、em、%等)。如果值为auto,则项目的尺寸随内容调整。
## Instructions
使用flex-basis为盒子设置初始值。给#box-1和#box-2添加 CSS 属性flex-basis。设置#box-1的尺寸初始值为10em,#box-2的尺寸初始值为20em。
## Tests
```yml
tests:
- text: '#box-1元素应有flex-basis属性。'
testString: assert($('#box-1').css('flex-basis') != 'auto');
- text: '#box-1的flex-basis应为10em。'
testString: assert(code.match(/#box-1\s*?{\s*?.*?\s*?.*?\s*?flex-basis:\s*?10em;/g));
- text: '#box-2元素应有flex-basis属性。'
testString: assert($('#box-2').css('flex-basis') != 'auto');
- text: '#box-2的flex-basis应为20em。'
testString: assert(code.match(/#box-2\s*?{\s*?.*?\s*?.*?\s*?flex-basis:\s*?20em;/g));
```
## Challenge Seed
## Solution
```html
// solution required
```