freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/css-flexbox/use-the-order-property-to-r...

1.7 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
587d78ae367417b2b2512aff Use the order Property to Rearrange Items 0 使用order属性重新排列项目

Description

order属性用于告诉CSS Flex项目在Flex容器中的显示顺序。默认情况下项目将以与源HTML相同的顺序显示。该属性将数字作为值可以使用负数。

Instructions

将CSS属性order添加到#box-1#box-2 。给#box-1一个值2#box-2一个值1。

Tests

tests:
  - text: '<code>#box-1</code>元素的<code>order</code>属性应设置为值2。'
    testString: 'assert($("#box-1").css("order") == "2", "The <code>#box-1</code> element should have the <code>order</code> property set to a value of 2.");'
  - text: '<code>#box-2</code>元素应该将<code>order</code>属性设置为值1。'
    testString: 'assert($("#box-2").css("order") == "1", "The <code>#box-2</code> element should have the <code>order</code> property set to a value of 1.");'

Challenge Seed

<style>
  #box-container {
    display: flex;
    height: 500px;
  }
  #box-1 {
    background-color: dodgerblue;

    height: 200px;
    width: 200px;
  }

  #box-2 {
    background-color: orangered;

    height: 200px;
    width: 200px;
  }
</style>

<div id="box-container">
  <div id="box-1"></div>
  <div id="box-2"></div>
</div>

Solution

// solution required