Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flex-direction: column-reverse except the first element

Tags:

html

css

flexbox

i have multiple article element which prefer order in reverse, but the first element is a header element and i need it to be sticky at top, how could i reverse all items but the first header element ?

#content {
  display: flex;
  flex-direction: column-reverse;
}

and

<div id="content">
  <header>something</header>

  <article>1</article>
  <article>2</article>
  <article>3</article>
  <article>4</article>
  <article>5</article>
</div>
like image 660
Sami Avatar asked Feb 05 '23 16:02

Sami


1 Answers

Use the order property. https://developer.mozilla.org/en-US/docs/Web/CSS/order

#content {
  display: flex;
  flex-direction: column-reverse;
}
header {
  order: 1;
}
<div id="content">
  <header>something</header>
  <article>1</article>
  <article>2</article>
  <article>3</article>
  <article>4</article>
  <article>5</article>
</div>
like image 104
Michael Coker Avatar answered Feb 07 '23 11:02

Michael Coker