aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/glossary/main_axis/index.html
blob: aaee256e7d0a0c819de9f76943ec259968debec9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
title: 主轴
slug: Glossary/Main_Axis
translation_of: Glossary/Main_Axis
original_slug: Glossary/主轴
---
<p>主轴是由弹性容器 {{glossary("flexbox")}} 中弹性方向 {{cssxref("flex-direction")}} 属性所定义的的。弹性方向 <code>flex-direction </code> 有4个可能的值,分别是:</p>

<ul>
 <li><code>row</code></li>
 <li><code>row-reverse</code></li>
 <li><code>column</code></li>
 <li><code>column-reverse</code></li>
</ul>

<p>选择行 <code>row</code> 或者 <code>row-reverse</code> 反向行,那么主轴方向就会沿着行的走向。</p>

<p><img alt="In this image the flex-direction is row which forms the main axis" src="https://mdn.mozillademos.org/files/15708/Basics1.png" style="display: block; height: 152px; margin: 0px auto; width: 522px;"></p>

<p>选择列 <code>column</code> 或者反向列 <code>column-reverse</code> ,那么主轴就会从上至下沿着块的走向。</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/15709/Basics2.png" style="display: block; height: 227px; margin: 0px auto; width: 709px;"></p>

<p>在主轴上,你可以用 <code>flex</code> 属性来增加可用空间,从而控制弹性元素的尺寸,你还可以用 <code>justify-content</code> 属性来控制元素周围的空间、间距。</p>

<h2 id="学习更多">学习更多</h2>

<h3 id="属性参考">属性参考</h3>

<div class="index">
<ul>
 <li>{{cssxref("flex-basis")}}</li>
 <li>{{cssxref("flex-direction")}}</li>
 <li>{{cssxref("flex-grow")}}</li>
 <li>{{cssxref("flex-shrink")}}</li>
 <li>{{cssxref("justify-content")}}</li>
 <li>{{cssxref("flex")}}</li>
</ul>
</div>

<h3 id="拓展阅读">拓展阅读</h3>

<ul>
 <li>CSS 弹性容器指南: <em><a href="/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox">Basic Concepts of Flexbox</a></em></li>
 <li>CSS 弹性容器指南: <em><a href="/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Aligning_Items_in_a_Flex_Container">Aligning items in a flex container</a></em></li>
 <li>CSS 弹性容器指南: <em><a href="/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Controlling_Ratios_of_Flex_Items_Along_the_Main_Ax">Controlling Ratios of flex items along the main axis</a></em></li>
</ul>

<div id="gtx-trans" style="position: absolute; left: 188px; top: 1222.14px;">
<div class="gtx-trans-icon"></div>
</div>