Files
freeCodeCamp/curriculum/challenges/japanese/01-responsive-web-design/applied-visual-design/push-elements-left-or-right-with-the-float-property.md
2022-01-20 20:30:18 +01:00

2.2 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
587d78a3367417b2b2512ace float プロパティで要素を左右に押しやる 0 https://scrimba.com/c/c2MDqu2 301066 push-elements-left-or-right-with-the-float-property

--description--

次の位置指定の方法では position は使用せず、要素の float プロパティを設定します。 フローティング要素はドキュメントの通常フローから削除され、その要素を内包する親要素の left または right に押しやられます。 フローティング要素が必要とする水平方向の幅を指定するために、よく width プロパティと共に使用されます。

--instructions--

与えられた HTML のマークアップは、sectionaside の要素が隣り合うように 2 カラムレイアウトにするのが良さそうです。 #left の要素の floatleft に、#right の要素の floatright に設定してください。

--hints--

id が left の要素の float の値は left に設定してください。

assert($('#left').css('float') == 'left');

id が right の要素の float の値は right に設定してください。

assert($('#right').css('float') == 'right');

--seed--

--seed-contents--

<head>
  <style>
    #left {

      width: 50%;
    }
    #right {

      width: 40%;
    }
    aside, section {
      padding: 2px;
      background-color: #ccc;
    }
  </style>
</head>
<body>
  <header>
    <h1>Welcome!</h1>
  </header>
  <section id="left">
    <h2>Content</h2>
    <p>Good stuff</p>
  </section>
  <aside id="right">
    <h2>Sidebar</h2>
    <p>Links</p>
  </aside>
</body>

--solutions--

<head>
  <style>
    #left {
      float: left;
      width: 50%;
    }
    #right {
      float: right;
      width: 40%;
    }
    aside, section {
      padding: 2px;
      background-color: #ccc;
    }
  </style>
</head>
<body>
  <header>
    <h1>Welcome!</h1>
  </header>
  <section id="left">
    <h2>Content</h2>
    <p>Good stuff</p>
  </section>
  <aside id="right">
    <h2>Sidebar</h2>
    <p>Links</p>
  </aside>
</body>