html - 如何在可滚动的页面底部显示页脚?
问题描述
我需要帮助在需要滚动的页面底部显示我的页脚。使用的代码仅适用于不需要滚动的页面。当前页脚显示在页面中间。它应该显示在页面底部。我尝试过做网站告诉我做的事情。网站包括: https ://www.freecodecamp.org/news/how-to-keep-your-footer-where-it-belongs-59c6aa05c59c/ https://css-tricks.com/couple-takes-sticky-footer /#there-is-flexbox 但是这两个网站都不起作用....
干杯
贾斯汀
这是我的 CSS 代码。
html, body {
height: 100%;
}
body {
background-color: #EEE;
font-family: Helvetica, Arial, sans-serif;
background-image: url (logo.png);
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
display: flex;
flex-direction: column;
}
h1, h2, h3 {
margin: 0;
}
a {
text-decoration: none;
color: blue;
}
#container {
background-color: white;
margin-left: auto;
margin-right: auto;
position: relative;
min-height: 100vh;
}
#header {
background-color: blue;
color: white;
text-align: center;
padding: 10px;
}
#content {
padding-top: 10px;
padding-left: 10px;
padding-right:10px;
padding-bottom: 2.5rem;
margin-right:0px;
min-height: 100vh;
}
#nav ul {
list-style-type: none;
}
#nav .selected {
font-family: bold;
}
#nav {
width: 18%;
float: left;
}
#main {
width: 60%;
float: right;
}
.content {
flex: 1 0 auto;
}
.footer {
flex-shrink: 0;
color:white;
background-color:black;
}
下面是我的 HTML 代码。
<!DOCTYPE html>
<?php
$database = "seriousdiseases";
$database = new mysqli('localhost', 'root', '', $database) or die ("Unable to connect to the
DB");
?>
<html>
<head>
<title>Ribose-5-phosphate isomerase deficiency</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<div id="container">
<div id="header">
<h1>Ribose-5-phosphate isomerase deficiency</h1>
</div>
<div class="content">
<div id="nav">
<h3>Navigation</h3>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="aboutUs.html">About Us</a></li>
<li><a href="video.html">Video</a></li>
<li><a href="seriousDiseases.html">Serious Diseases</a></li>
</ul>
</div>
<div id="main">
<table>
<tr>
<th>Disease</th>
<th>Symptoms</th>
</tr>
<?php
$result = mysqli_query($database, "select disease, symptom from
feature") or die ("Unable to connect to the DB");
while ($row = mysqli_fetch_array($result)){
print("<tr><td>" . $row[0] . "</td><td>" . $row[1] . "</td>
</tr>");
}
$database->close();
?>
</table>
</div>
</div>
<footer class="footer">
Copyright © 2020 CLINIC SCOPE
</footer>
</div>
</body>
</html>
解决方案
页脚不应在容器中。如果你把它从那里拿出来,你的问题就会得到解决。我建议将其用于其他标签。(标题,导航等)
推荐阅读
- php - PHP new DateTime() 抛出无效的 date.timezone 值
- forms - SwiftUI:当同一个表单上有一个 Picker 时,我如何导航到 NavigationLink?
- jquery - Jquery 不使用 html() 设置内容
- python - twint 发布时间数据“2020–04–29 00:00:00”与格式“%Y-%m-%d %H:%M:%S”不匹配
- java - 语音识别和 Sphinx 入门
- kibana - Kibana 不允许在可选值上使用计算字段,有解决方法吗?
- verilog - 我不明白这个带复制的定义宏
- swift - 在 Swift 中保存游戏数据 [硬币、宝石、用硬币购买的颜色]
- python - Python pydantic,使祖先的每个字段都是可选的
- c# - 如何获取所有 PlayerPrefs 键以创建 Drop() 函数?