html - 按钮未与绝对定位 HTML CSS 的浏览器底部对齐

标签 html css css-position

我有一个元素 ( <button id="foo">FAQ</button> )。我有那个按钮的 CSS:

#foo {
    position: absolute;
    bottom: 0px;/* I tried using other units */
    left: 0px;/* same thing here*/
}

问题是该元素最终出现在屏幕底部(而不是像我尝试做的浏览器窗口),当您向下滚动时,它会停留在那里。我使用的是谷歌浏览器 53.0.x 版。我在Microsoft Edge中试过了,问题依旧。该按钮没有父级(除了主体)。任何帮助将不胜感激!

编辑

截图: error screenshot

我想让按钮在您向下滚动到底部时显示出来,而绝对定位无法做到这一点。 我可以看出我的问题没有得到很好的理解,所以我想做一些区分可能有助于使我的问题更容易理解:

screen:窗口的可见部分(依赖于滚动) 浏览器窗口:整个网页(独立于滚动)

最佳答案

不是position: absolute;而是position: fixed;

Check this out了解可能的选项以及它们之间的区别:

absolute The element is positioned relative to its first positioned (not static) ancestor element

fixed The element is positioned relative to the browser window

关于html - 按钮未与绝对定位 HTML CSS 的浏览器底部对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40251608/

相关文章:

javascript - 如何使滚动到目标平滑

html - 如何使用网格 Bootstrap 在左侧制作垂直导航全宽

javascript - ng-repeat 垂直溢出

javascript - 如何使用touchmove找到偏移位置?

css - 使用 Bootstrap.js 修复导航栏

jquery - 使用 jQuery 调整绝对定位的 div

android - 在 Text View android 中设置 Span 样式的 HTML 文本

javascript - ASP.NET Ajax 不调用 Url

css - 在 CSS 中将 div 放置在居中的 div 周围

html - 为什么doe的固定定位div在滚动而不是停留在指定位置?