希望容器之內的物件可以並行接續排列,並且每個物件都有固定比例占據該容器
display
屬性為flex
.container{
display: flex;
}
在內層物件中,各自定義佔據的寬度或剩餘空間的分配比例
當 外層容器的空間足夠 的情況:
width
,會佔據固定寬度300pxwidth
,會佔據固定寬度200pxflex
比例,則會依比例分配剩餘的空間為了避免 外層容器空間不足 ,可以min-width
輔助定義最小的寬度
min-width
,所以被擠壓到完全沒有空間定義「不換行」(flex-wrap
預設值即為no-wrap
,可省略不寫),可能會壓縮內層物件的寬度
.container{
display: flex;
flex-wrap: no-wrap;
}
定義「自動換行」
.container{
display: flex;
flex-wrap: wrap;
}
定義「換行後反轉」
.container{
display: flex;
flex-direction: row;
flex-wrap: wrap-reverse;
}
定義排序方向為「左到右」(flex-direction
預設值即為row
,可省略不寫)
.container{
display: flex;
flex-direction: row;
}
定義排序方向為「右到左」
.container{
display: flex;
flex-direction: row;
}
定義排序方向為「上到下」
.container{
display: flex;
flex-direction: column;
}
定義排序方向為「下到上」
.container{
display: flex;
flex-direction: column-reverse;
}
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing