【问题标题】:Flex items exceed container height when wrapped in FirefoxFlex 项目在 Firefox 中包装时超过容器高度
【发布时间】:2017-01-16 16:21:19
【问题描述】:

在当前的 Firefox (50) 中,当 header 中的两个 item 环绕低于 715px 时,较低的 item 延伸到 header 的高度以下。我玩过每个项目的 flex 速记语句和最小宽度,并尝试使用 @media 查询具有该最大宽度的屏幕,但无法停止。页面是here

CSS:

header {
  display: flex;
  flex-flow: row-reverse wrap;
  justify-content: space-around;
  height: 320px;
  padding: 20px 0;
}
.sec1 {
  flex: 4 2 200px;
  min-width: 200px;
  padding-right: 6vw;
  padding-left: 3vw;
  margin-top: 2vw;
  @media only screen and (max-width: 1350px) {
    flex: 6 1 0;
    margin-top: 6vw;
  }
}
.sec2 {
  align-self: center;
  flex: 7 0 250px;
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-start;
  p {
    width: 40%;
    text-align: right;
    margin-right: 30px;
    margin-bottom: 25px;
    align-items: flex-start;
  }
}
.accent {
  font-size: 20px;
  color: #967832;
  line-height: 24px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 50px;
  border: 8px solid black;
  padding: 12px;
}
.container {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: stretch;
}
section {
  display: box;
  display: flex;
  padding: 15px;
  flex: 1 0 350px;
  margin-top: 3vw;
  margin-left: 6vw;
}
<header>
  <div class="sec1">
    <img src="http://www.moonwards.com/img/MWLogo-for-black-bckgnd.svg" alt="Moonwards" id="logo">
  </div>
  <div class="sec2">
    <p class="accent">What would it really be like
      <br>to live on the Moon?</p>
  </div>
</header>
<div class="container">
  <section>
    <div class="outerDiv">
      <div class="innerDiv intro">
        <h1>Realistic Lunar Colony, Coming Online</h1>
        <p>
          This project is building a series of virtual colonies on the Moon. They will be richly detailed and interactive presentations that are entirely plausible, technically and scientifically. They will examine all the questions, consider all the implications.
          When humanity undertakes ventures on the scale of space settlement, it matters a great deal how many people have given it real thought beforehand. These colonies serve that purpose.
        </p>
      </div>
    </div>
  </section>
  <aside>
		<div class="sideDiv"id="RSS-feed">
      <p id="item2" class="atom"><span class="datetime">Mon, 07 Nov 2016 19:50:00 GMT</span><span class="title"><a href="http://www.moonwards.com/">Lalande map</a></span><span class="description">Kim has finished composing an extremely detailed map of the Lalande crater. It is a huge file, but available at request.</span>
      </p>
		</div>

问题似乎是 Firefox 在包装时没有考虑容器的高度。有什么方法可以阻止溢出?

【问题讨论】:

    标签: css firefox flexbox


    【解决方案1】:

    您的代码过于复杂。其中大部分可以安全地移除。尝试排除过程来查明问题。

    这是您的代码的修订版本(在 Chrome 和 FF 上测试):

    <header>
      <img id="logo" src="http://www.moonwards.com/img ... svg" alt="Moonwards" id="logo">
      <p id="note">What would it really be like<br> to live on the Moon?</p>
    </header>
    

    revised codepen

    【讨论】:

    • 我会记住这是一般做法,但在这种情况下没有帮助。我用一个包裹标志的类 'sec1' 的 div 更新了页面,并将该类从标志中删除。它也在做同样的事情。
    • 实际上,在发布我的答案之前,我将您的图像包装在一个 div 中,并且布局有效。意思是,下部元素没有溢出标题,布局看起来就像在 Chrome 中一样。这就是我发布此答案的原因。
    • 那么您的操作方式与实时页面之间肯定存在其他差异。实时页面无法正常工作。
    • 您能解决问题吗?为此,我无能为力。修复后,我在 Chrome 和 FF 中看到相同的布局。
    • 没有。类似的行为发生在另一个页面上,它也发生在 Chrome 中。还有其他事情我完全不明白。我尝试只按下标题,但 Chrome 和 Firefox 上的布局完全不同,并且通常根据屏幕宽度而变得丑陋,并且每次尝试修复都会导致重叠问题再次出现。我想也许我应该编辑这个问题,但我现在很迷茫。
    猜你喜欢
    • 2021-11-23
    • 1970-01-01
    • 1970-01-01
    • 2019-09-13
    • 1970-01-01
    • 1970-01-01
    • 2015-08-08
    • 2019-04-30
    • 2019-02-28
    相关资源
    最近更新 更多