【问题标题】:Why overflow:hidden is working only in chrome and not in firefox为什么溢出:隐藏仅在 chrome 中有效,而在 firefox 中无效
【发布时间】:2019-03-25 16:33:12
【问题描述】:

overflow:hidden 属性在 google chrome 中工作,而不是在 firefox 和 microsoft edge 中工作,我正在使用它为侧边栏提供整个页面高度,以便它具有相同的正文高度。

风格:

.sidebar {
   position:absolute;
   width: 225px;
   background-color: #4b4b4b;
   margin-bottom: -5000px;
   padding-bottom: 5000px;
   overflow: hidden;
  }

html:

<div class="sidebar">
    <div class="nav-item active">
    <a class="nav-link border-bottom border-warning {{Request::path()=='home' ? 'selectioné' : ''}}" href="home"><span>Dashboard</span></a>
    </div>
    <div class="nav-item">
    <a class="nav-link border-bottom border-warning {{Request::path()=='register' ? 'selectioné' : ''}}" href="register"><span>Ajout Compte</span></a>
    </div>
    <div class="nav-item">
    <a class="nav-link border-bottom border-warning" href="*******"><span>*******</span></a>
    </div>
    <div class="nav-item">
    <a class="nav-link border-bottom border-warning" href="/telescope" target="_blank"><span>Telescope</span></a>
    </div>
    <div class="nav-item">
    <a class="nav-link border-bottom border-warning" href="tables.html"><span>Tables3</span></a>
    </div>
    <div class="nav-item">
    <a class="nav-link border-bottom border-warning" href="tables.html"><span>Tables4</span></a>
    </div>
</div>

正文:

body {
  position: relative;
  min-height: 100vh;
  padding-bottom: 4.5rem;
 }

页脚:

footer {
   position: absolute;
   border-radius: 12px;
   right: 0;
   bottom: 0;
   width: calc(100% - 225px);
   height: 80px;
   background-color: #e2e2e2;
  text-align: center;
  padding-top: 28px;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
}

主要:

.main {
  width: 100%;
  padding-left: 225px;
  padding-top: 11px;
  padding-bottom: 30px;
}

我怎样才能使它在所有浏览器中都能正常工作?

【问题讨论】:

  • 你也可以分享HTML吗?谢谢

标签: css firefox overflow sidebar


【解决方案1】:

试试这个:

.sidebar {
  width: 225px;
  background-color: #4b4b4b;
  position: absolute;
  top: 60px;
  bottom: 0;
}

【讨论】:

    【解决方案2】:

    .sidebar css 中删除margin-bottom: -5000px; padding-bottom: 5000px; 并添加min-height: 100vh;,希望它能解决您的问题。谢谢

    .sidebar {
       position:absolute;
       width: 225px;
       min-height: 100vh;
       background-color: #4b4b4b;
       overflow: hidden;
    }
    

    【讨论】:

    • 不,它确实隐藏了正文溢出,如果您的正文内容很长,那就不好了
    • 我只是更新了上面的代码,希望对你有所帮助。谢谢
    • 不,我没有工作同样的事情溢出没有发挥作用
    • 溢出工作正常,您只需删除paddingmargin 并添加min-height。谢谢
    猜你喜欢
    • 2011-10-22
    • 1970-01-01
    • 2018-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-14
    • 1970-01-01
    • 2011-10-14
    相关资源
    最近更新 更多