2018-09-30 23:01:58 +01:00
---
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'
2019-08-05 09:17:33 -07:00
forumTopicId: 301108
2021-01-13 03:31:00 +01:00
dashedName: use-the-flex-basis-property-to-set-the-initial-size-of-an-item
2018-09-30 23:01:58 +01:00
---
2020-11-27 19:02:05 +01:00
# --description--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
The `flex-basis` property specifies the initial size of the item before CSS makes adjustments with `flex-shrink` or `flex-grow` .
The units used by the `flex-basis` property are the same as other size properties (`px` , `em` , `%` , etc.). The value `auto` sizes items based on the content.
# --instructions--
Set the initial size of the boxes using `flex-basis` . Add the CSS property `flex-basis` to both `#box-1` and `#box-2` . Give `#box-1` a value of `10em` and `#box-2` a value of `20em` .
# --hints--
The `#box-1` element should have a `flex-basis` property.
```js
assert($('#box -1').css('flex-basis') != 'auto');
```
The `#box-1` element should have a `flex-basis` value of `10em` .
```js
assert(code.match(/#box -1\s*?{\s*?.*?\s*?.*?\s*?flex-basis:\s*?10em;/g));
```
The `#box-2` element should have the `flex-basis` property.
```js
assert($('#box -2').css('flex-basis') != 'auto');
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
The `#box-2` element should have a `flex-basis` value of `20em` .
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
assert(code.match(/#box -2\s*?{\s*?.*?\s*?.*?\s*?flex-basis:\s*?20em;/g));
```
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --seed--
## --seed-contents--
2018-09-30 23:01:58 +01:00
```html
< style >
#box -container {
display: flex;
height: 500px;
}
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
#box -1 {
background-color: dodgerblue;
height: 200px;
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
}
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
#box -2 {
background-color: orangered;
height: 200px;
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
}
< / style >
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
< div id = "box-container" >
< div id = "box-1" > < / div >
< div id = "box-2" > < / div >
< / div >
```
2020-11-27 19:02:05 +01:00
# --solutions--
2018-11-05 19:09:44 +03:00
2018-11-03 18:21:22 -04:00
```html
< style >
#box -container {
display: flex;
height: 500px;
}
#box -1 {
background-color: dodgerblue;
height: 200px;
flex-basis: 10em;
}
2018-09-30 23:01:58 +01:00
2018-11-03 18:21:22 -04:00
#box -2 {
background-color: orangered;
height: 200px;
flex-basis: 20em;
}
< / style >
< div id = "box-container" >
< div id = "box-1" > < / div >
< div id = "box-2" > < / div >
< / div >
2018-09-30 23:01:58 +01:00
```