gpt4 book ai didi

html - 防止我的固定页脚重叠内容

转载 作者:太空宇宙 更新时间:2023-11-04 05:54:05 25 4
gpt4 key购买 nike

我有以下代码来创建我的固定页脚:(类似于 https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_fixed_footer)

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: red;
color: white;
text-align: center;
}
</style>
</head>
<body>

<h2>Fixed/Sticky Footer Example</h2>
<p>The footer is placed at the bottom of the page.</p>
<p>The footer is placed at the bottom of the page.</p>
.....
<p>The footer is placed at the bottom of the page.</p>
<p>The footer is placed at the bottom of the page.</p>
<p>The footer is placed at the bottom of the page.</p>
<p>The footer is placed at the bottom of the page.</p>
<p>The footer is placed at the bottom of the page.</p>
<p>N-2 element</p>
<p>N-1 element</p>
<p>N element</p>

<div class="footer">
<p>Footer</p>
</div>

</body>
</html>

固定属性运行良好,但我没有看到我的内容的最后一行。页脚与它重叠:

enter image description here

如何避免?

最佳答案

您需要为页脚添加高度,然后添加 padding-bottom: footerHeightpx;到正文元素

body {
padding-bottom: footerHeightHere
}

关于html - 防止我的固定页脚重叠内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57975105/

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