php div与页脚重叠
有人能帮我吗?我试图弄明白为什么2php div与页脚重叠,php,html,css,Php,Html,Css,有人能帮我吗?我试图弄明白为什么2divs相互重叠 这就是它的外观,我无法在主体下方找到页脚,即白色框 我的身体代码是: <body style = 'background-image: url("/images/sitebg.jpg")'> <?php include 'header.php'; ?> <div class="mainmenu"> <div class="dropdown"> <button cla
div
s相互重叠
这就是它的外观,我无法在主体下方找到页脚,即白色框
我的身体代码是:
<body style = 'background-image: url("/images/sitebg.jpg")'>
<?php include 'header.php'; ?>
<div class="mainmenu">
<div class="dropdown">
<button class="dropbtn">Menu</button>
<div class="dropdown-content">
<a href="#">Blog</a>
<a href="#">Recipes</a>
<a href="#">Gameplay Footage</a>
</div>
</div>
</div>
<div id="main" class="site-main">
</div>
<div>
<?php include 'footer.php'; ?>
</div>
</body>
页脚代码为:
</div>
<div class="site-footer"
<center><div><c>Powered by</c> <lo1><a href="" target="_blank">Phoenix78</lo1> <c>2017 ©</c></div></center>
</div>
</div>
<html>
<head><link rel="stylesheet" href="style.css"></head>
<body class="body">
<header>
<div class="container">
<center><h1></h1>
</div>
</header>
</body>
</html>
因此,根据注释,您的主HTML文件应包含:
<!DOCUMENT html>
<html>
<head>
<?php include 'header.php'; ?>
</head>
<body style = 'background-image: url("/images/sitebg.jpg")'>
<div class="mainmenu">
<div class="dropdown">
<button class="dropbtn">Menu</button>
<div class="dropdown-content">
<a href="#">Blog</a>
<a href="#">Recipes</a>
<a href="#">Gameplay Footage</a>
</div>
</div>
</div>
<div id="main" class="site-main">
</div>
<div class="site-footer">
<?php include 'footer.php'; ?>
</div>
</body>
</html>
您的footer.php
文件应仅输出以下HTML:
<link rel="stylesheet" href="style.css">
<title>Title</title>
<span class="c">Powered by</span> <span class="lo1"><a href="" target="_blank">Phoenix78</a></span> <span class="c">2017 ©</span>
中心未正确关闭
此外,已弃用,应避免使用
<html>
<head><link rel="stylesheet" href="style.css"></head>
**<body class="body">**
<header>
<div class="container">
**<center>**<h1></h1>
</div>
</header>
****
****
此外,您的代码在文档上放置了两个正文标记您所说的“重叠”是什么意思?您认为输出应该是什么?PHP生成HTML。PHP没有重叠。发布生成的源代码。如果footer.php
有
您要关闭正文两次,也可以查看。你的头也会关闭身体。我推荐一个HTML教程。到处都是。我很确定你的HTML格式不正确。例如,如果您的主体代码包括标题代码,那么您的实际HTML文档将在主体标记之后定义--您的第一个主体标记,因为您的代码是以上面的方式编写的,你的页面将有2个主体标签。c和lo1是css类。我试着把它放进去,它采用了css设计,即使你不这样写代码。我不熟悉php,它工作了,所以我留下了它。使用index.php后,输出部分是代码。你建议我将在css中添加需要更新的代码,以恢复样式那么,非常感谢你!p、 我已经添加了当前外观的屏幕截图。我看到了,我只是查看了结果。我只是添加了所需的CSS,请注意,我所做的唯一一件事就是添加text align:center
到.site footer
类,然后我在c
和lo1
之前添加了一个
,将它们转换为类选择器。这应该可以解决问题。当然,我还没有分析它,所以它可能仍然重叠,但一旦我弄清楚截图上是什么,然后我会检查一下。有一个进展,但仍然没有定位。页脚和身体仍然并排,而不是页脚在身体下面。再次感谢我学会了分配感谢你们,这不是我的问题
<!DOCUMENT html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<title>Title</title>
</head>
<body style = 'background-image: url("/images/sitebg.jpg")'>
<div class="mainmenu">
<div class="dropdown">
<button class="dropbtn">Menu</button>
<div class="dropdown-content">
<a href="#">Blog</a>
<a href="#">Recipes</a>
<a href="#">Gameplay Footage</a>
</div>
</div>
</div>
<div id="main" class="site-main">
</div>
<div class="site-footer">
<span class="c">Powered by</span> <span class="lo1"><a href="" target="_blank">Phoenix78</a></span> <span class="c">2017 ©</span>
</div>
</body>
</html>
.site-footer {
text-align: center;
float: left;
display: block;
padding: 3.5em;
}
.c {
color: black;
font-family: "Agency FB";
font-size: 16px;
position: relative;
}
.lo1 {
color: black;
font-family: "Agency FB";
font-size: 22px;
text-shadow: 2px 2px Orange;
text-align: center;
}
.site-main {
margin-bottom: 0;
}
.mainmenu {
display: block;
background-color: white;
margin-bottom: 15px;
margin-left: 0;
margin-top: 0;
border: 2px solid black;
}
<html>
<head><link rel="stylesheet" href="style.css"></head>
**<body class="body">**
<header>
<div class="container">
**<center>**<h1></h1>
</div>
</header>