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

83 lines
1.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: 587d78ab367417b2b2512af0
title: '使用 display: flex 定位兩個盒子'
challengeType: 0
videoUrl: 'https://scrimba.com/p/pVaDAv/cgz3QS7'
forumTopicId: 301105
dashedName: use-display-flex-to-position-two-boxes
---
# --description--
這節我們會使用不同的挑戰方式來學習如何使用 CSS 更靈活地佈局元素。 首先我們會通過一個挑戰來解釋原理然後通過操作一個簡單的推文組件來應用彈性盒子flexbox
只要在一個元素的 CSS 中添加 `display: flex;`,就可以使用其它 flex 屬性來構建響應式頁面了。
# --instructions--
請爲 `#box-container` 添加 `display` 屬性,並設置其屬性值爲 `flex`
# --hints--
`#box-container` 應具有 `display`屬性,其屬性值應爲 `flex`
```js
assert($('#box-container').css('display') == 'flex');
```
# --seed--
## --seed-contents--
```html
<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--
```html
<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>
```