freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/css-flexbox/use-the-align-self-property...

2.0 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
587d78af367417b2b2512b00 Use the align-self Property 0 使用align-self属性

Description

flex项的最终属性是align-self 。此属性允许您单独调整每个项目的对齐方式而不是一次性设置它们。这很有用因为使用CSS属性float clearvertical-align其他常用调整技术对flex项不起作用。 align-self接受与align-items相同的值,并将覆盖align-items属性设置的任何值。

Instructions

将CSS属性align-self添加到#box-1#box-2 。给#box-1一个中心值,给#box-2一个flex-end值。

Tests

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

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