小白教程
所有教程
关于
Search
172.70.178.204
172.70.178.204
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Css3 pr flex direction”的源代码
本页内容
上一节:
Css3_pr_flex_flow
下一节:
Css3_pr_flex_wrap
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:flex-direction}}[[Category:css reference|106]] = CSS flex-direction 属性 = [[css reference|CSS 参考手册]] 设置 <div> 元素内弹性盒元素的方向为相反的顺序: <sample title="" desc="" lang="html" hererun="1"> div { display:flex; flex-direction:row-reverse; } </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <style> #main { width: 400px; height: 400px; border: 1px solid #c3c3c3; display: -webkit-flex; /* Safari */ -webkit-flex-direction: row-reverse; /* Safari 6.1+ */ display: flex; flex-direction: row-reverse; } #main div { width: 50px; height: 50px; } </style> </head> <body> <div id="main"> <div style="background-color:coral;">A</div> <div style="background-color:lightblue;">B</div> <div style="background-color:khaki;">C</div> <div style="background-color:pink;">D</div> <div style="background-color:lightgrey;">E</div> <div style="background-color:lightgreen;">F</div> </div> <p><b>注意:</b> Internet Explorer 10 及更早版本浏览器不支持 flex-direction 属性。</p> <p><b>注意:</b> Safari 6.1 及更新版本通过 -webkit-flex-direction 属性支持该属性。</p> </body> </html> </run> == 浏览器支持 == 表格中的数字表示支持该属性的第一个浏览器的版本号。 紧跟在 -webkit-, -ms- 或 -moz- 后的数字为支持该前缀属性的第一个版本。 {| class="table table-striped table-hover" ! 属性 ! Chrome ! Internet Explorer / Edge ! Firefox ! Safari ! Opera |- | flex-direction | 29.021.0 -webkit- | 11.010.0 -ms- | 28.018.0 -moz- | 9.06.1 -webkit- | 17.0 |} == 定义和用法 == flex-direction 属性规定灵活项目的方向。 '''注意:'''如果元素不是弹性盒对象的元素,则 flex-direction 属性不起作用。 {| class="table table-striped table-hover" |width="50%"| 默认值: |width="50%"| row |- | 继承: | 否 |- | 可动画化: | 否。请参阅 [[css animatable|可动画化(animatable)]]。 |- | 版本: | CSS3 |- | JavaScript 语法: | object.style.flexDirection="column-reverse" <run name=""> <!DOCTYPE html> <html> <head> <style> #main { width: 350px; height: 350px; border: 1px solid #c3c3c3; display: flex; flex-direction: row; } #main div { width: 50px; height: 50px; } </style> </head> <body> <div id="main"> <div style="background-color:coral;">A</div> <div style="background-color:lightblue;">B</div> <div style="background-color:khaki;">C</div> <div style="background-color:pink;">D</div> <div style="background-color:lightgrey;">E</div> <div style="background-color:lightgreen;">F</div> </div> <p>点击“尝试一下”按钮设置 flexDirection 属性的值为 "column-reverse"。</p> <button onclick="myFunction()">尝试一下</button> <script> function myFunction() { document.getElementById("main").style.flexDirection = "column-reverse"; } </script> <p><b>注意:</b>Internet Explorer 和 Safari 不支持 flexDirection 属性。</p> </body> </html> </run> |} == CSS 语法 == <pre> flex-direction: row|row-reverse|column|column-reverse|initial|inherit;</pre> == 属性值 == {| class="table table-striped table-hover" !width="33%"| 值 !width="33%"| 描述 !width="33%"| 实例 |- | row | 默认值。灵活的项目将水平显示,正如一个行一样。 | <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <style> #main { display: flex; flex-direction:row; } #main div { width: 40px; height: 40px; } </style> </head> <body> <div id="main"> <div style="background-color:coral;">A</div> <div style="background-color:lightblue;">B</div> <div style="background-color:khaki;">C</div> <div style="background-color:pink;">D</div> <div style="background-color:lightgrey;">E</div> <div style="background-color:lightgreen;">F</div> </div> </body> </html> </run> |- | row-reverse | 与 row 相同,但是以相反的顺序。 | <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <style> #main { display: flex; flex-direction:row-reverse; } #main div { width: 40px; height: 40px; } </style> </head> <body> <div id="main"> <div style="background-color:coral;">A</div> <div style="background-color:lightblue;">B</div> <div style="background-color:khaki;">C</div> <div style="background-color:pink;">D</div> <div style="background-color:lightgrey;">E</div> <div style="background-color:lightgreen;">F</div> </div> </body> </html> </run> |- | column | 灵活的项目将垂直显示,正如一个列一样。 | <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <style> #main { display: flex; flex-direction:column; } #main div { width: 40px; height: 40px; } </style> </head> <body> <div id="main"> <div style="background-color:coral;">A</div> <div style="background-color:lightblue;">B</div> <div style="background-color:khaki;">C</div> <div style="background-color:pink;">D</div> <div style="background-color:lightgrey;">E</div> <div style="background-color:lightgreen;">F</div> </div> </body> </html> </run> |- | column-reverse | 与 column 相同,但是以相反的顺序。 | <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <style> #main { display: flex; flex-direction:column-reverse; } #main div { width: 40px; height: 40px; } </style> </head> <body> <div id="main"> <div style="background-color:coral;">A</div> <div style="background-color:lightblue;">B</div> <div style="background-color:khaki;">C</div> <div style="background-color:pink;">D</div> <div style="background-color:lightgrey;">E</div> <div style="background-color:lightgreen;">F</div> </div> </body> </html> </run> |- | initial | 设置该属性为它的默认值。请参阅 [[css initial|initial]]。 | <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> <style> #main { display: flex; flex-direction:initial; } #main div { width: 40px; height: 40px; } </style> </head> <body> <div id="main"> <div style="background-color:coral;">A</div> <div style="background-color:lightblue;">B</div> <div style="background-color:khaki;">C</div> <div style="background-color:pink;">D</div> <div style="background-color:lightgrey;">E</div> <div style="background-color:lightgreen;">F</div> </div> </body> </html> </run> |- | inherit | 从父元素继承该属性。请参阅 [[css inherit|inherit]]。 | |} == 相关文章 == CSS 参考手册:[[css3 pr flex|flex 属性]] CSS 参考手册:[[css3 pr flex basis|flex-basis 属性]] CSS 参考手册:[[css3 pr flex flow|flex-flow 属性]] CSS 参考手册:[[css3 pr flex grow|flex-grow 属性]] CSS 参考手册:[[css3 pr flex shrink|flex-shrink 属性]] CSS 参考手册:[[css3 pr flex wrap|flex-wrap 属性]] [[css reference|CSS 参考手册]]
返回至“
Css3 pr flex direction
”。
上一节:
Css3_pr_flex_flow
下一节:
Css3_pr_flex_wrap