<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Flex-order</title>
</head>
<body>
<div>
<ul class="flex-box">
<li>Home</li>
<li>About</li>
<li>Portfolio</li>
<li>Contact</li>
</ul>
</div>
</body>
</html>
.flex-box {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.flex-box li {
padding: 10px;
list-style-type: none;
background: red;
color: #fff;
border: 1px solid tomato;
box-shadow: 1px 0px 0px 1px tomato;
}
.flex-box :first-child {
order: 1;
}
.flex-box :last-child {
order: -1;
}
/*Notes: Highest ordered items are displayed later than that of lowest order items*/
/*In the above example "Home" will be displayed last than other 3 and "Contact" will be displayed first as it's order is lower than others */
/*Flex items with same order will be displayed in same order as source order such as one after other*/
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.