- Flexbox 教程
- Flexbox - 主页
- Flexbox - 概览
- Flexbox - Flex 容器
- Flexbox - Flex-Direction
- Flexbox - Flex-Wrap
- Flexbox - 内容对齐
- Flexbox - 项目对齐
- Flexbox - 内容排列
- Flexbox - Flex-Order
- Flexbox - 柔性
- Flexbox - 自我对齐
- Flexbox 有用资源
- Flexbox - 快速指南
- Flexbox - 有用资源
- Flexbox - 讨论
Flexbox - Flex-Order
flex-order 属性用于定义 Flexbox 项目的顺序。
以下示例演示了 order 属性。此处,我们创建了六个带有标签一、二、三、四、五、六的色块,按相同顺序排列,然后我们使用 flex-order 属性将它们重新排序为一、二、五、六、三、四的顺序。
<!doctype html> <html lang = "en"> <style> .box{ font-size:35px; padding:15px; } .box1{background:green;} .box2{background:blue;} .box3{background:red; order:1} .box4{background:magenta; order:2} .box5{background:yellow;} .box6{background:pink;} .container{ display:inline-flex; border:3px solid black; flex-direction:rows; flex-wrap:wrap; } </style> <body> <div class = "container"> <div class = "box box1">One</div> <div class = "box box2">two</div> <div class = "box box3">three</div> <div class = "box box4">four</div> <div class = "box box5">five</div> <div class = "box box6">six</div> </div> </body> </html>
它将生成以下结果 -
- ve 顺序
您还可以给 order 分配 -ve 值,如下所示。
<!doctype html> <html lang = "en"> <style> .box{ font-size:35px; padding:15px; } .box1{background:green;} .box2{background:blue;} .box3{background:red; order:-1} .box4{background:magenta; order:-2} .box5{background:yellow;} .box6{background:pink;} .container{ display:inline-flex; border:3px solid black; flex-direction:row; flex-wrap:wrap; } </style> <body> <div class = "container"> <div class = "box box1">One</div> <div class = "box box2">two</div> <div class = "box box3">three</div> <div class = "box box4">four</div> <div class = "box box5">five</div> <div class = "box box6">six</div> </div> </body> </html>
它将生成以下结果 -
广告