2.9 KiB
2.9 KiB
id | title | challengeType | videoUrl | forumTopicId | localeTitle |
---|---|---|---|---|---|
587d78ae367417b2b2512afd | Use the flex-basis Property to Set the Initial Size of an Item | 0 | https://scrimba.com/p/pVaDAv/c3d9nCa | 301108 | Используйте свойство flex-basis для установки начального размера элемента |
Description
flex-basis
указывает начальный размер элемента до того, как CSS выполнит корректировки с flex-shrink
или flex-grow
. Единицы, используемые свойством flex-basis
такие же, как и другие свойства размера ( px
, em
, %
и т. Д.). Значение auto
определяет размеры элементов на основе содержимого.
Instructions
flex-basis
. Добавьте свойство CSS flex-basis
как в #box-1
и в #box-2
. Дайте #box-1
значение 10em
и #box-2
значение 20em
.
Tests
tests:
- text: The <code>#box-1</code> element should have a <code>flex-basis</code> property.
testString: assert($('#box-1').css('flex-basis') != 'auto');
- text: The <code>#box-1</code> element should have a <code>flex-basis</code> value of <code>10em</code>.
testString: assert(code.match(/#box-1\s*?{\s*?.*?\s*?.*?\s*?flex-basis:\s*?10em;/g));
- text: The <code>#box-2</code> element should have the <code>flex-basis</code> property.
testString: assert($('#box-2').css('flex-basis') != 'auto');
- text: The <code>#box-2</code> element should have a <code>flex-basis</code> value of <code>20em</code>.
testString: assert(code.match(/#box-2\s*?{\s*?.*?\s*?.*?\s*?flex-basis:\s*?20em;/g));
Challenge Seed
<style>
#box-container {
display: flex;
height: 500px;
}
#box-1 {
background-color: dodgerblue;
height: 200px;
}
#box-2 {
background-color: orangered;
height: 200px;
}
</style>
<div id="box-container">
<div id="box-1"></div>
<div id="box-2"></div>
</div>
Solution
<style>
#box-container {
display: flex;
height: 500px;
}
#box-1 {
background-color: dodgerblue;
height: 200px;
flex-basis: 10em;
}
#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>