Files
Nicholas Carrigan (he/him) 3da4be21bb chore: seed chinese traditional (#42005)
Seeds the chinese traditional files manually so we can deploy to
staging.
2021-05-05 22:43:49 +05:30

1.5 KiB
Raw Permalink Blame History

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
587d78ab367417b2b2512af0 使用 display: flex 定位兩個盒子 0 https://scrimba.com/p/pVaDAv/cgz3QS7 301105 use-display-flex-to-position-two-boxes

--description--

這節我們會使用不同的挑戰方式來學習如何使用 CSS 更靈活地佈局元素。 首先我們會通過一個挑戰來解釋原理然後通過操作一個簡單的推文組件來應用彈性盒子flexbox

只要在一個元素的 CSS 中添加 display: flex;,就可以使用其它 flex 屬性來構建響應式頁面了。

--instructions--

請爲 #box-container 添加 display 屬性,並設置其屬性值爲 flex

--hints--

#box-container 應具有 display屬性,其屬性值應爲 flex

assert($('#box-container').css('display') == 'flex');

--seed--

--seed-contents--

<style>
  #box-container {
    height: 500px;

  }

  #box-1 {
    background-color: dodgerblue;
    width: 50%;
    height: 50%;
  }

  #box-2 {
    background-color: orangered;
    width: 50%;
    height: 50%;
  }
</style>
<div id="box-container">
  <div id="box-1"></div>
  <div id="box-2"></div>
</div>

--solutions--

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

  #box-1 {
    background-color: dodgerblue;
    width: 50%;
    height: 50%;
  }

  #box-2 {
    background-color: orangered;
    width: 50%;
    height: 50%;
  }
</style>
<div id="box-container">
  <div id="box-1"></div>
  <div id="box-2"></div>
</div>