使div到达页面顶部时,我遇到了问题。我想删除页面顶部的空白。请在HTML下方找到:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Mastermind</title>
<link rel="stylesheet" type="text/css" href="Style.css" />
</head>
<body>
<div class="top">
<div class="header">
<table width="100%";>
<tr valign="middle">
<td style="width:30%">
<img alt="a" src="Images/images.jpg" />
</td>
<td valign="middle" style="float:right; width:70%;">
Call us:+1 800 123 4567 | F T G
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
下面是CSS:
body
{
background-color:#F0F8FF;
width:100%;
vertical-align:top;
height:100%;
margin:0px;
padding:0px;
}
.top
{
background-color:#666;
width:100%;
height:25%;
margin:0px 0px 0px 0px;
margin-top:0px;
margin-left:0px;
margin-right:0px;
padding:0px;
}
.header
{
width:70%;
margin-left:15%;
margin-right:15%;
border:solid 1px black;
margin-top:50px;
}
我希望将div顶部放置在浏览器的顶部。
最佳答案
只需删除margin-top:50px;
内的keep margin-top:0px;
或.header