繁体   English   中英

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

[英]Prevent my Fixed Footer from overlapping content

我有以下代码来创建固定的页脚:(类似于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> 

固定资产效果很好,但是我看不到竞争的最后一行。 页脚与之重叠:

在此处输入图片说明

我该如何避免呢?

您需要在页脚中添加高度,然后在底部添加填充:footerHeightpx; 身体元素

body {
  padding-bottom: footerHeightHere
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM