html - flex 方向 : column-reverse except the first element

标签 html css flexbox

我有多个 article 元素,它们喜欢倒序排列,但第一个元素是 header 元素,我需要它粘在顶部, 我如何反转除第一个 header 元素之外的所有元素?

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

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

  <article>1</article>
  <article>2</article>
  <article>3</article>
  <article>4</article>
  <article>5</article>
</div>

最佳答案

使用 order 属性。 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>

关于html - flex 方向 : column-reverse except the first element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43313868/

相关文章:

javascript - jQuery(..).load(..) 不工作

html - css 需要在没有字体 css 的情况下工作

html - 如何在不使用背景图像的情况下创建视差效果?

javascript - 当元素出现在视口(viewport)中时运行函数

jquery - 如何更改导航选项卡的背景颜色

css - CSS Flexbox系统中的xs,md,lg是什么意思?

html - 如何将 svg 嵌入到 svg 中?

jquery - 为什么我的导航在使用 Fullpage.js 时不是垂直的?

html - 两个 div 与省略号并排 - 最小宽度问题

css - 有一个固定的 <ImageBackground> 在我滚动时不会自行移动