gpt4 book ai didi

html - CSS 位置 : fixed and background-attachment: fixed

转载 作者:行者123 更新时间:2023-11-28 09:38:36 30 4
gpt4 key购买 nike

我有我的 <footer>设置为 background-attachment: fixed但这留下了我的<p>标签正常滚动。如果我设置 position: fixed到我的<p>标签,它们会跳转到页面顶部。有什么办法可以做与 background-attachment: fixed 相同的事情吗?与 <p>标签?我试过 position: absolute但这导致与 position: fixed 相同的结果.

最佳答案

如果您的问题是关于您的页脚干扰您的 <p>标签,您可以尝试设置 background-attachment: fixed在你的 body CSS中,而不是你的页脚CSS。

例如:

body    { background-image:url('../images/background.jpg'); background-attachment: fixed; }

至于固定与绝对:

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 - CSS 位置 : fixed and background-attachment: fixed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25457087/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com