html - 页脚不在正确的位置
问题描述
我的网站页脚在 LOCALHOST 上按预期显示。但是当上传到服务器并通过www.mushtor.com访问时,它就搞砸了。下面是代码:
<!DOCTYPE html>
<html>
<head>
<title>Mushtor</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="globalstyle.css">
<link rel="stylesheet" type="text/css" href="homeCategories.css">
</head>
<body>
<div class="topnav">
<a class="active" href="index.html">হোম পেজ</a>
</div>
<div class="header">
<h1>MUSHTOR</h1>
<p>স্ব-শিক্ষায় সহায়ক</p>
</div>
<div class="row">
<div class="leftcolumn" style="padding-left: 30px; padding-right: 30px;">
<div class="container">
<h2 style="text-align: center;">শিক্ষার বিষয়বস্তু নির্বাচন করুন</h2>
<div id="cat1">
<a href="mathematics.html" class="categoryLinks">গণিত</a>
</div>
<div id="cat2">
<a href="physics.html" class="categoryLinks">পদার্থবিদ্যা</a>
</div>
<div id="cat3">
<a href="windows10.html" class="categoryLinks">উইন্ডোজ ১০</a>
</div>
<div style="clear:both;"></div>
</div>
</div>
<div class="rightcolumn">
<h2>লেখক সম্পর্কে</h2>
<p>আমি একজন শিক্ষার্থী। আমার ক্ষুদ্র জ্ঞান আপনাদের সাথে ভাগ করছি।</p>
</div>
</div>
<div class="footer">
<p>কপিরাইট © 2020 Mushtor.com</p>
</div>
</body>
</html>
globalstyle.css 中页脚类的代码如下:
.footer{
position: absolute;
bottom: 0;
width: 100%;
background-color: green;
color: white;
text-align: center;
}
请参阅下面的截图:
解决方案
您应该将其设置position
为fixed
而不是absolute
,例如:
<!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: green;
color: white;
text-align: center;
}
</style>
</head>
<body>
<h2>Example footer</h2>
<div class="footer">
<p>Footer</p>
</div>
</body>
</html>
推荐阅读
- javascript - 关于WebRTC的offer和answer问题
- azure - Azure 数据工厂通过访问密钥连接到 Blob 存储
- c - 使用选择排序对数组进行排序
- sql - 在 PostgreSQL 12 上使用 WITH 查找唯一值、计算重复项并对其进行排名
- c# - 具有私有添加方法或调整能力的 C# 字典
- python - 如何在flutter中使用starflut导入python包?
- spring - shedlock - 使用没有 spring @Scheduled 注释
- c - Char 数组似乎覆盖了其他数据
- vim - 如何在 Vim 中取消映射反斜杠?
- php - 我可以将按钮单击请求从 js 发送到 php