gpt4 book ai didi

html - 相同的 CSS/HTML 不同的结果?

转载 作者:行者123 更新时间:2023-11-28 04:46:43 25 4
gpt4 key购买 nike

我有一个 HTML 文件,我总是在其中使用相同的 header (我将其包含在每个页面的顶部)我使用 CSS 来设计这个标题...

整体没有顶部空间,很好。现在我在 index.php 的页面顶部有空间,而在 contact.php 的顶部没有空间,尽管它具有相同的标题和完全相同的 CSS 文件/strong> 在此处链接输入代码...

这怎么可能?

(抱歉代码示例不好,但是网站太复杂了……)

.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>

最佳答案

只要我们没有看到包含的 php 文件中的所有代码,我们就只能猜测。谈到 CSS,您可以尝试在您的元素中使用“重置 CSS”文件。 Reset 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;
}

所以不妨试一试,看看效果如何。

关于html - 相同的 CSS/HTML 不同的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40920515/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com