Files
freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/css-flexbox/use-the-flex-grow-property-to-expand-items.md
Oliver Eyton-Williams dec409a4bd fix: s/localeTitle/title/g
2020-10-06 23:10:08 +05:30

1.8 KiB
Raw Blame History

id, challengeType, videoUrl, forumTopicId, title
id challengeType videoUrl forumTopicId title
587d78ae367417b2b2512afc 0 https://scrimba.com/p/pVaDAv/c2p78cg 1301111 使用 flex-grow 属性扩展项目

Description

flex-shrink相对的是flex-grow。你应该还记得,flex-shrink会在容器太小时对元素作出调整。相应地,flex-grow会在容器太大时对元素作出调整。 例子与上一个挑战相似,如果一个项目的flex-grow属性值为 1,另一个项目的flex-grow属性值为 3,那么后者会较前者扩大 3 倍。

Instructions

#box-1#box-2添加 CSS 属性flex-grow#box-1的值设为 1#box-2的值设为 2

Tests

tests:
  - text: <code>#box-1</code>元素应有<code>flex-grow</code>属性,其值应为 <code>1</code>。
    testString: assert($('#box-1').css('flex-grow') == '1');
  - text: <code>#box-2</code>元素应有<code>flex-grow</code>属性,其值应为 <code>2</code>。
    testString: assert($('#box-2').css('flex-grow') == '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