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

2.7 KiB
Raw Blame History

id title challengeType videoUrl forumTopicId localeTitle
587d78af367417b2b2512b00 Use the align-self Property 0 https://scrimba.com/p/pVaDAv/cMbvzfv 301107 Использовать свойство align-self

Description

Конечным свойством для элементов flex является align-self . Это свойство позволяет настраивать выравнивание каждого элемента отдельно, вместо того, чтобы устанавливать их все одновременно. Это полезно, так как другие общие методы настройки с использованием свойств CSS float , clear и vertical-align не работают на гибких элементах. align-self принимает те же значения, что и align-items и отменяет любое значение, заданное свойством align-items .

Instructions

Добавьте свойство CSS align-self в #box-1 и #box-2 . Дайте #box-1 значение центра и дайте #box-2 значение flex-end.

Tests

tests:
  - text: The <code>#box-1</code> element should have the <code>align-self</code> property set to a value of center.
    testString: assert($('#box-1').css('align-self') == 'center');
  - text: The <code>#box-2</code> element should have the <code>align-self</code> property set to a value of flex-end.
    testString: assert($('#box-2').css('align-self') == '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

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

  #box-2 {
    background-color: orangered;
    align-self: flex-end;
    height: 200px;
    width: 200px;
  }
</style>

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