1.9 KiB
1.9 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d78ae367417b2b2512afc | Use the flex-grow Property to Expand Items | 0 | 使用flex-grow属性扩展项目 |
Description
flex-shrink
相反的是flex-grow
属性。回想一下,当容器缩小时, flex-shrink
控制项目的大小。当父容器展开时, flex-grow
属性控制项的大小。使用上一个挑战中的类似示例,如果一个项目的flex-grow
值为1而另一个项目的flex-grow
值为3,则值为3的项目将增长为另一个项目的三倍。 Instructions
flex-grow
添加到#box-1
和#box-2
。将#box-1
的值设为1,将#box-2
的值设为2。 Tests
tests:
- text: '<code>#box-1</code>元素应将<code>flex-grow</code>属性设置为值1。'
testString: 'assert($("#box-1").css("flex-grow") == "1", "The <code>#box-1</code> element should have the <code>flex-grow</code> property set to a value of 1.");'
- text: '<code>#box-2</code>元素应将<code>flex-grow</code>属性设置为值2。'
testString: 'assert($("#box-2").css("flex-grow") == "2", "The <code>#box-2</code> element should have the <code>flex-grow</code> property set to a value of 2.");'
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