Flexbox div重叠和响应

时间:2018-03-21 19:47:35

标签: html css flexbox

我正在尝试使用flexbox使一些元素重叠并交错,但我还需要它在移动时响应堆栈。我是flexbox的新手,想看看我是否能得到一些帮助使这个响应。下面是我的html和css。正如您在运行代码段时所看到的那样,我不希望它看起来如何。这是我的codepen,这是我想要的桌面布局,然后我希望div在移动时堆叠:https://codepen.io/ascarb1/full/zWZVRw/

非常感谢任何帮助。



body {
  max-width: 1600px;
  width: 95%;
  margin: 0 auto;
}

.home-story-container {
  display: flex;
  margin: 10em auto;
  flex-direction: column;
  justify-content: space-between;
  align-items: left;
  float: none;
}

.home-story-container .home-story-text-block {
  height: 373px;
  width: 618px;
  background: #ddd;
  align-self: flex-start;
  flex-shrink: 0;
  margin-left: 15em;
}

.home-story-container .home-story-text-block .home-story-text-content {
  width: 60%;
  margin: 4em 0 0 4em;
}

.home-story-container .home-story-image-block {
  width: 640px;
  align-self: flex-end;
  flex-shrink: 0;
  margin-right: 14em;
  margin-top: -23em;
}

.home-story-container .home-story-video-block {
  width: auto;
  align-self: flex-start;
  flex-shrink: 0;
  margin-left: 21em;
  margin-top: -10em;
}

.home-story-container .home-story-quote-block {
  align-self: flex-end;
  flex-shrink: 0;
  margin-right: 16em;
  margin-top: -9.5em;
  width: 413px;
}

<div class="col-md-12">
  <div class="home-story-container">
    <div class="home-story-text-block">
      <div class="home-story-text-content">
        <h1>Lorem ipsum dolor sit amet</h1>
        <br>
        <p>Lorem ipsum dolor sit amet, malesuada quisque sit consectetuer adipiscing odit, sed tortor leo nunc, a vel erat ultricies.</p>
      </div>
    </div>
    <div class="home-story-image-block"><img src="http://via.placeholder.com/640x373"></div>
    <div class="home-story-video-block"><iframe width="560" height="315" src="https://www.youtube.com/embed/SkgTxQm9DWM?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen=""></iframe></div>
    <div class="home-story-quote-block">
      <p>Lorem ipsum dolor sit amet, Lorem ipsum dolor sit amet<br><span>Lorem ipsum dolor sit amet.</span></p>
    </div>
  </div>
</div>
&#13;
&#13;
&#13;

0 个答案:

没有答案