HTML CSS examples for CSS Layout:Flex Wrap
Create layout using flex-flow:row-reverse to wrap and reverse items in reverse order
<html lang="en"> <head> <style> ul {<!--from w ww . j a v a 2s . c o m--> list-style:none; min-height:91px; width:501px; padding:6px; background-color:Chartreuse; display:flex; flex-wrap:wrap; } li { display:inline-block; min-width:121px; height:91px; text-align:center; line-height:91px; margin-right:6px; margin-bottom:6px; background-color:yellow; } li:nth-last-child(4n + 3):first-child { margin-left:126px; background-color:blue; } li:nth-last-child(4n + 2):first-child { margin-left:251px; background-color:pink; } li:nth-last-child(4n + 1):first-child { margin-left:376px; background-color:WhiteSmoke; } li:nth-last-child(4n):first-child { background-color:OrangeRed; } </style> </head> <body translate="no"> <ul> <li>1</li> </ul> <hr> <ul> <li>1</li> <li>2</li> </ul> <hr> <ul> <li>1</li> <li>2</li> <li>3</li> </ul> <hr> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> </ul> <hr> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> </ul> <hr> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> </ul> <hr> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> </ul> <hr> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> <li>8</li> </ul> <hr> <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> <li>8</li> <li>9</li> </ul> </body> </html>