2016-12-01 104 views
0

我有一個HTML文件,我總是使用相同的標題(我包括它在每一個頁面的頂部) 我用CSS樣式這個頭......相同的CSS/HTML不同的結果?

整體機身頂部有沒有空間,這就是好。 現在我在index.php的頁面頂部有空間,在contact.php頂部沒有空格,雖然它有相同的標題和完全相同的CSS文件鏈接輸入代碼在這裏。 ..

這怎麼可能?

(對不起,壞的代碼示例,但該網站是複雜的,以顯示它...)

.body{ 
 
\t margin: 0 auto; 
 
\t width:70%; 
 
\t clear: both; 
 
} 
 
.mainHeader img{ 
 
\t width: 50%; 
 
\t height: auto; 
 
\t margin-top:0px; 
 
\t margin-bottom:20px; 
 
\t display: block; 
 
\t margin-right:auto; 
 
\t 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" > 
 
\t <link rel="stylesheet" href="css/style.css"/> 
 
\t <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
 
</head> 
 

 
<body class="body"> 
 
<header class="mainHeader"> 
 
\t <img src="logo.png"></img> 
 
<nav> 
 
\t <ul> 
 
\t \t <li class="#"><a href="index.php">home</a></li> 
 
\t  <li class="#"><a href="contact.php">contact</a></li> 
 
\t </ul> 
 
</nav> 
 
</header> 
 
</body> 
 
</html>

+1

無法分辨實際的源文件。在開發人員控制檯中查看您使用的任何瀏覽器,查看應用的填充和邊距以及相關的樣式。某處有些不同之處。 – junkfoodjunkie

+0

擺脫'',圖像標籤不會關閉。 – tomaroo

+1

對不起,我不是一個PHP的人,但你的頭包含'html','head'和'body'標籤似乎很奇怪。我認爲這些包含的內容被認爲是部分的意見。另外,不要使用隧道視覺......問題可能不在於頭文件或頭文件CSS,而可能是index.php頁面上的標記(如一個流浪字符或無效標記)或該頁面樣式。 – zgood

回答

0

只要我們沒有看到所有的代碼包含的php文件,我們只能猜測。 談到CSS,您可能會嘗試在您的項目中使用「重置CSS」文件。重置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; 
} 

所以,也許試一試,看看它是如何去。

+0

感謝您的快速回復,但它並沒有幫到我很多......我發現問題是,Chrome瀏覽器在我的身上搜索了一個用戶代理sylesheet ......它是有線的,它只是一些網頁...你有一個想法如何刪除身體上的用戶代理樣式表?謝謝你......馬呂斯 – Marius