【发布时间】:2012-03-02 13:58:16
【问题描述】:
抱歉,这似乎是一个重复的问题,但他们都没有解决我的问题。
所有边距、边框和内边距设置都设置为 0px,除了主页面 div 的 margin-left 和 margin-right 设置为 15px 的任一侧。至少我看不到任何我忘记将其中之一设置为 0px...
由于某种原因,页面顶部的 div 不会与页面顶部对齐。
如果我在<body> 标记和<div class="main"> 标记之间放置任何文本,这将很难显示在屏幕顶部,但任何文本都位于 div“main”标记或 div“header”中标签将与屏幕顶部有大约 15px 的边距。
header.php:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php header('Content-Type: text/html; charset=utf-8'); ?>
<title><?php echo $title; ?></title>
<link href='css/main.css' rel='stylesheet' type='text/css' />
</head>
<body>
<div class='main'>
<div class="header">
<img src="images/header1.png" id="header" />
</div>
<p class='heading_1'>Welcome to D T Hourn Photography</p>
<p class='bodycontent'>
Introduction blob
</p>
<p class='bodycontent'>
Albums:
</p>
css.main:
html
{
border:0px;
padding:0px;
margin:0px;
}
body
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-style: normal;
background-image: url('../images/bg1.png');
background-attachment:fixed;
padding:0px;
margin:0px;
border:0px;
}
.main
{
top:0px;
margin-top:0px;
margin-right:15px;
margin-left:15px;
margin-bottom:0px;
border-top:0xp;
border-left: 2px outset #445566;
border-right: 2px outset #445566;
width:93%;
max-width:1400px;
background: rgb(222, 222, 222);
background-color:rgba(255, 255, 255, 0.6);
}
.header
{
border-bottom: 2px groove red;
margin:0px;
background-image:url('../images/header1.png');
background-size:100% 100%;
height:200px;
}
img#header
{
width:100%;
height:200px;
vertical-align: bottom;
border:0px;
padding:0px;
margin:0px;
}
.heading_1
{
font-family: Verdana, Arial, Helvetica, sans-serif;
height:1.5em;
font-weight: bold;
color: #000000;
}
.heading_2
{
font-weight: bold;
}
table
{
border:1px solid #0000ff;
padding:0px;
border-collapse:collapse;
background-color:#ffffff;
}
.tables_heading
{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 1em;
font-weight: bold;
background-color: #99ccff;
border-bottom:1px solid #0000ff;
}
编辑:从 header.php 文件中添加了额外的代码。如前所述,如果我在两者之间放置纯文本,那么该文本就很难靠在浏览器的顶部。但 div 之间的任何内容都有约 15 像素的边框。
可以在http://dthourn.com/photography看到实际的在线网站(我到目前为止所做的)
实时版本在 Firefox(至少在我的计算机上)中呈现我想要的效果,但在 I.E 或谷歌浏览器上不呈现。它不会像我想要的那样在我本地计算机上的任何浏览器中呈现。
【问题讨论】:
-
您好像漏掉了一些 html,只有头部,我们无法从中看出太多。
-
你能给你的HTML部分提供使用
.header和.main的元素吗?给定的部分是没有帮助的。 -- 我想这只是你的标题将主要内容向下推。 -
<?php header命令在那个位置不起作用,但我认为这不会导致问题。 -
正确的边框顶部:0xp;在'.main'上