css - 具有三个背景图像并居中于同一位置的 Flexbox?

标签 css flexbox background-image

在使用 Flexbox 时是否可以让三个 div 具有相同的背景图像,并且其中两个像图像显示的那样旋转?

该图片显示了我的旧网站草稿,但我是通过旧方法获得该结果的。现在我想尝试只使用 flexbox。我希望它们成为三个独立的 div 的原因是因为我希望能够在它们上放置框阴影,而无需实际更新原始图像本身。

我遇到的另一个问题是它们需要一起扩展,因此两个 paper_sheets 需要根据包含页面信息的顶层纸改变它的大小,就像您在图像上看到的那样。

enter image description here

最佳答案

试试这个

<style>
  main {
    align-items: flex-start;
    display: flex;
    justify-content: space-evenly;
    margin: 0 auto;
    height: 480px;
    width: 480px;  
  }
  aside, section {
    padding: 0 1em;
  }
  aside, section, section:before, section:after {
    background: beige;
    border: 1px solid;
    box-shadow: 0 0 10px 0 rgba(0,0,0,0.5);
  }
  section {
    height: 260px;
    position: relative;
    width: 260px;
  }
  section:after,
  section:before {
    content: "";
    height: 100%;
    left: 0;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: -1;
  }
  section:after {
    filter: brightness(0.8);
    transform: rotate(3.6deg);
  }
  section:before {
    filter: brightness(0.9);
    transform: rotate(-3.6deg);
  }
  h1, h2, h3, h4, h5, h6, p {
    margin: 1em 0;
  }
</style>

<main>
  <section>
    <h1>Lorem ipsum</h1>
    <p>Lorem ipsum dolor sit amet</p>
  </section>
  <aside>
    <h4>Lorem ipsum</h4>
    <p>Lorem ipsum</p>
  </aside>
</main>

关于css - 具有三个背景图像并居中于同一位置的 Flexbox?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53470924/

相关文章:

javascript - 两个图表的 flexbox 溢出屏幕

html - 如何使用 flexbox 将一个 div 居中放置在另一个 div 中?

css - 具有背景颜色的透明背景图像

html - 简单的 Angular 路由更改动画在移动设备上不起作用?

jquery - 如何使用 jQuery 从元素中获取边框半径?

html - 具有可滚动容器的复杂 Flexbox 布局

css - Div 背景图像不适用于 ie

html - 如何使用内联 block 属性将文本放在背景图像下方

css - 两列和边框中的div动态宽度

html - 高度 :100% overfills the content