2.1 KiB
2.1 KiB
id, title, challengeType, videoUrl, forumTopicId, localeTitle
| id | title | challengeType | videoUrl | forumTopicId | localeTitle |
|---|---|---|---|---|---|
| 587d78ad367417b2b2512afb | Use the flex-shrink Property to Shrink Items | 0 | https://scrimba.com/p/pVaDAv/cd3PBfr | 301113 | 使用 flex-shrink 属性收缩项目 |
Description
flex-shrink属性。使用之后,如果 flex 容器太小,该项目会自动缩小。当容器的宽度小于里面所有项目的宽度,项目就会自动压缩。
项目的flex-shrink属性接受 number 类型的值。数值越大,该项目与其他项目相比会被压缩得更厉害。例如,如果一个项目的flex-shrink属性值为 1,另一个项目的flex-shrink属性值为 3,那么后者相比前者会受到 3 倍压缩。
Instructions
#box-1和#box-2添加 CSS 属性flex-shrink,#box-1的值设为 1,#box-2的值设为 2。
Tests
tests:
- text: <code>#box-1</code>元素应有<code>flex-shrink</code>属性,其值应为 <code>1</code>.
testString: assert($('#box-1').css('flex-shrink') == '1');
- text: <code>#box-2</code>元素应有<code>flex-shrink</code>属性,其值应为 <code>2</code>.
testString: assert($('#box-2').css('flex-shrink') == '2');
Challenge Seed
<style>
#box-container {
display: flex;
height: 500px;
}
#box-1 {
background-color: dodgerblue;
width: 100%;
height: 200px;
}
#box-2 {
background-color: orangered;
width: 100%;
height: 200px;
}
</style>
<div id="box-container">
<div id="box-1"></div>
<div id="box-2"></div>
</div>
Solution
// solution required