【问题标题】:Is it possible to build this header layout using Flexbox CSS?是否可以使用 Flexbox CSS 构建此标题布局?
【发布时间】:2022-02-14 05:07:25
【问题描述】:

我一直在试图弄清楚如何在 CSS Flexbox 中实现这种布局,但到目前为止还没有找到一种不涉及隐藏副本以仅在桌面上显示的方法来使其工作。使用 Flexbox 可以做到这一点吗?

我正在努力实现的图像示例:

【问题讨论】:

  • 网格解决方案是否可以接受?
  • @KakSarkar 是的,将不胜感激任何可能的建议。我认为 flexbox 将是唯一的方法,很乐意尝试任何事情 :)

标签: html css flexbox tailwind-css


【解决方案1】:

grid 中的解决方案会更好,这是一个工作示例,移动版本的断点发生在 800px,

我建议你阅读Grid Area Template 系统,它以非常现代和漂亮的方式制作这些布局

.parent{
  width: 100%;
  height:100vh;
  display: grid;
  grid-template-columns: 200px 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  grid-template-areas: "blue red""blue red""green green";
  gap: 10px;
}

.blue{
  grid-area: blue;
  width: 200px;
  background: blue;
}

.red{
  grid-area: red;
  width: 100%;
  background: red;
}

.green{
  grid-area: green;
  width: 100%;
  height: 100%;
  background: green;
}

@media screen and (max-width: 800px){
  .parent{
 grid-template-areas:    "blue red"
                         "blue green";
     grid-template-rows: 1fr 1fr;
  }
}
<div class="parent">
  <div class="red"></div>
  <div class="green"></div>
  <div class="blue"></div>
</div>

【讨论】:

    猜你喜欢
    • 2019-04-29
    • 2014-06-29
    • 1970-01-01
    • 1970-01-01
    • 2020-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-13
    相关资源
    最近更新 更多