我有一个HTML文件,我总是使用相同的标题(我将它包含在每个页面的顶部) 我用CSS来设置这个标题的样式......
整个身体顶部没有空间,这很好。 现在我在index.php页面顶部有空格,contact.php顶部没有空格,虽然它有 相同的标题和完全相同的CSS文件 链接输入代码到这里......
怎么可能?
(对不好的代码示例感到抱歉,但网站很复杂,以显示它...)
.body{
margin: 0 auto;
width:70%;
clear: both;
}
.mainHeader img{
width: 50%;
height: auto;
margin-top:0px;
margin-bottom:20px;
display: block;
margin-right:auto;
margin-left:auto;
}

//index file
<?php
include 'includes/overall/header.php';
?>
//contact file
<?php
include 'includes/overall/header.php';
?>
//header file
<html>
<head>
<title>Website Title</title>
<meta charset="UTF-8" >
<link rel="stylesheet" href="css/style.css"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body class="body">
<header class="mainHeader">
<img src="logo.png"></img>
<nav>
<ul>
<li class="#"><a href="index.php">home</a></li>
<li class="#"><a href="contact.php">contact</a></li>
</ul>
</nav>
</header>
</body>
</html>
&#13;
答案 0 :(得分:0)
只要我们没有看到包含的php文件中的所有代码,我们可能只会猜测。 谈到CSS,你可以尝试使用&#34;重置CSS&#34;文件在你的项目中。重置CSS是一个css代码,用于清除页面中元素的所有边距,填充等。你可以看看http://cssreset.com/scripts/eric-meyer-reset-css/
代码在这里:
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
所以也许试一试,看看它是怎么回事。