我想我已经把所有东西都安排好了,但它似乎根本不起作用。
这是索引.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>
这是标题顶部.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>
谢谢大家的双手!
你需要了解include
的作用。从字面上看,"包含"文件中的所有内容都将放在您调用该函数的位置。因此,在这种情况下,您实际上将整个HTML文档放在另一个文档的<head>
中。
标题顶部.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>
标签根本不属于那里。这需要放在文档的正文中。
看起来您应该从标题顶部.php文件中删除<header>...</header>
以外的所有内容。 您已经在 index 中定义了 html 和 head 标签.php因此您无需在 headertop.php 中再次执行此操作。 但是,我不确定您是否真的希望标题块位于页面的标题部分内。不应该在身体里吗?
你可以
这样做。
索引.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>
标题顶部.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>
您不需要有两个相同的元标记或声明的文档类型、头部或身体标记。当然,我建议您使用require_once
而不是include
.