【问题标题】:CSS: Footer appears over main content on browser size shrinkCSS:页脚出现在浏览器尺寸缩小的主要内容上
【发布时间】:2017-03-27 15:18:15
【问题描述】:

我创建了一个前端计算器,并在页面底部添加了一个“启动说明”按钮。单击该按钮会展开为模式,显示操作计算器的说明。

这是页脚 HTML 的一部分

<div id="instructions">
    <!-- Button trigger modal -->
    <button type="button" class="btn btn-primary btn-large" data-toggle="modal" data-target="#myModal">
      Launch Instructions
    </button>

fixedposition是靠近屏幕底部的页脚,但我没想到即使浏览器缩小它也会留在原处,从而导致页脚出现过度计算器本身。

这是页脚css -

#instructions {
  position: fixed;
  left: 44%;
  bottom: 0px;
  z-index: 1049;
  font-family: 'Courgette', cursive;
}

#instructions button {

  text-transform: uppercase;
  opacity: 0.6;
}

这是Codepen 上的完整应用程序。

我不确定如何使页脚和“启动说明”按钮保持在计算器下方,即使屏幕缩小也是如此。也许我需要一个媒体查询来更改buttonz-index

@media screen and (max-height: 300px) {
    #instructions button {
    z-index: -1;
    }

}

非常感谢!

【问题讨论】:

标签: css position z-index footer sticky-footer


【解决方案1】:

只需执行以下操作:

  • z-index 更改为1#instructions
  • #wrapper添加z-index: 2

CSS

#instructions {
  z-index: 1;
}
#wrapper {
  z-index: 2;
}

预览

CodePen:http://codepen.io/anon/pen/vyGPRR

【讨论】:

  • 但这会将按钮放在计算器应用程序下方。现在,如果您缩小浏览器,则无法单击按钮并获得说明对话框。我一直在寻找一种方法来确保按钮总是出现在计算器应用程序之后,并且总是可点击的。
  • @Manish 啊...现在我明白了。好的,我会检查并通知您。
  • @Manish 看看这个:Sticky Footer 是你需要的。
  • 非常感谢!粘性页脚似乎工作得很好,我会浏览所有不同的版本!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-10-09
  • 1970-01-01
  • 1970-01-01
  • 2013-11-03
  • 2021-07-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多