Flexbox Tutorial
Flexbox Useful Resources
Selected Reading
- Flexbox - Align Self
- Flexbox - Flexibility
- Flexbox - Flex-Order
- Flexbox - Align Content
- Flexbox - Align Items
- Flexbox - Justifying Contents
- Flexbox - Flex-Wrap
- Flexbox - Flex-Direction
- Flexbox - Flex Containers
- Flexbox - Overview
- Flexbox - Home
Flexbox Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Flexbox - Flex-Order
Flexbox - Flex-Order
The flex-order property is used to define the order of the flexbox item.
The following example demonstrates the order property. Here we are creating six colored boxes with the labels one, two, three, four, five, six, arranged in the same order, and we are reordering them in the order one, two, five, six, three, four, using the flex-order property.
<!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:inpne-flex; border:3px sopd black; flex-direction:rows; flex-wrap:wrap; } </style> <body> <span class = "container"> <span class = "box box1">One</span> <span class = "box box2">two</span> <span class = "box box3">three</span> <span class = "box box4">four</span> <span class = "box box5">five</span> <span class = "box box6">six</span> </span> </body> </html>
It will produce the following result −
- ve ordering
You can also assign –ve values to the order as shown below.
<!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:inpne-flex; border:3px sopd black; flex-direction:row; flex-wrap:wrap; } </style> <body> <span class = "container"> <span class = "box box1">One</span> <span class = "box box2">two</span> <span class = "box box3">three</span> <span class = "box box4">four</span> <span class = "box box5">five</span> <span class = "box box6">six</span> </span> </body> </html>
It will produce the following result −
Advertisements