2.4 KiB
2.4 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d78ae367417b2b2512afd | Use the flex-basis Property to Set the Initial Size of an Item | 0 | 使用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: '<code>#box-1</code>元素应该具有<code>flex-basis</code>属性。'
testString: 'assert($("#box-1").css("flex-basis") != "auto", "The <code>#box-1</code> element should have a <code>flex-basis</code> property.");'
- text: '<code>#box-1</code>元素的<code>flex-basis</code>值应为<code>10em</code> 。'
testString: 'assert(code.match(/#box-1\s*?{\s*?.*?\s*?.*?\s*?flex-basis:\s*?10em;/g), "The <code>#box-1</code> element should have a <code>flex-basis</code> value of <code>10em</code>.");'
- text: '<code>#box-2</code>元素应该具有<code>flex-basis</code>属性。'
testString: 'assert($("#box-2").css("flex-basis") != "auto", "The <code>#box-2</code> element should have the <code>flex-basis</code> property.");'
- text: '<code>#box-2</code>元素的<code>flex-basis</code>值应为<code>20em</code> 。'
testString: 'assert(code.match(/#box-2\s*?{\s*?.*?\s*?.*?\s*?flex-basis:\s*?20em;/g), "The <code>#box-2</code> element should have a <code>flex-basis</code> value of <code>20em</code>.");'
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
// solution required