我想我已经把所有东西放到位,但似乎根本没有用。
这是index.php。我已经包含了头部,也许它会影响整个文件。:
<html>
<head>
<title>HOME</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="description" content="Slide Down Box Menu with jQuery and CSS3" />
<meta name="keywords" content="jquery, css3, sliding, box, menu, cube, navigation,
portfolio, thumbnails"/>
<link rel="shortcut icon" href="images/art_favicon.png" type="image/x-
icon"/>
<link rel="stylesheet" href="css/body.css" type="text/css" media="screen"/>
<link rel="stylesheet" href="css/headertop.css" type="text/css" media="screen"/>
<style>
body{
background-image: url(images/graphy.png);
font-family:Arial, Helvetica, sans-serif;
margin: 0;
padding: 0;
}
</style>
<?php
include ("headertop.php");
?>
</head>
<body>
<div id="contents">
</div>
</body>
</html>
这是headertop.php:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="description" content="Slide Down Box Menu with jQuery and CSS3" />
<meta name="keywords" content="jquery, css3, sliding, box, menu, cube, navigation,
portfolio, thumbnails"/>
<link rel="shortcut icon" href="images/art_favicon.png" type="image/x-
icon"/>
<link rel="stylesheet" href="css/headertop.css" type="text/css" media="screen"/>
<header>
<div id="headertop">
<div id="adams">
<p>
<span style="color: #F60;">A</span>ncajas
<span style="color: #F60;">D</span>igital
<span style="color: #F60;">A</span>rts &
<span style="color: #F60;">M</span>edia
<span style="color: #F60;">S</span>olutions
</p>
</div>
</div>
</header>
</head>
</html>
谢谢你的帮助!
答案 0 :(得分:4)
您需要了解include
的作用。字面上,“包含”文件中的所有内容都将放在您调用该函数的位置。因此,在这种情况下,您实际上将整个HTML文档放在另一个的<head>
内。
headertop.php应该只是:
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="description" content="Slide Down Box Menu with jQuery and CSS3" />
<meta name="keywords" content="jquery, css3, sliding, box, menu, cube, navigation, portfolio, thumbnails"/>
<link rel="shortcut icon" href="images/art_favicon.png" type="image/x-icon"/>
<link rel="stylesheet" href="css/headertop.css" type="text/css" media="screen"/>
<header>
标记根本不属于那里。这需要放在你的文件正文中。
答案 1 :(得分:1)
看起来您应该从headertop.php文件中删除<header>...</header>
之外的所有内容。您已经在index.php中定义了html和head标记,因此您无需在headertop.php中再次执行此操作。但是我不确定你真的希望你的标题块在页面的头部内。它不应该在体内吗?
答案 2 :(得分:0)
你可以这样做。
的index.php
<!DOCTYPE html>
<html>
<head>
<title>HOME</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta name="description" content="Slide Down Box Menu with jQuery and CSS3" />
<meta name="keywords" content="jquery, css3, sliding, box, menu, cube, navigation,
portfolio, thumbnails"/>
<link rel="shortcut icon" href="images/art_favicon.png" type="image/x-
icon"/>
<link rel="stylesheet" href="css/body.css" type="text/css" media="screen"/>
<link rel="stylesheet" href="css/headertop.css" type="text/css" media="screen"/>
<style>
body{
background-image: url(images/graphy.png);
font-family:Arial, Helvetica, sans-serif;
margin: 0;
padding: 0;
}
</style>
<?php
require_once("headertop.php");
?>
</head>
<body>
<div id="contents">
</div>
</body>
</html>
headertop.php
<header>
<div id="headertop">
<div id="adams">
<p>
<span style="color: #F60;">A</span>ncajas
<span style="color: #F60;">D</span>igital
<span style="color: #F60;">A</span>rts &
<span style="color: #F60;">M</span>edia
<span style="color: #F60;">S</span>olutions
</p>
</div>
</div>
</header>
您不需要拥有两个相同的元标记或声明的Doctype,head或body标记。当然,我建议您使用require_once
代替include
。