0

我正在尝试为页面的部分标签设置页边距顶部。但是当我为特定部分标签设置页边距顶部时,标题标签也会随之下降。请告诉我为部分标签设置 margin-top 的正确方法是我的 css。id 容器是我试图设置边距的部分标签的 id

body{
 background-color:#F7F7F7;
}

#logo
{
background-image:url('../Images/LogoEB.jpg');
background-repeat:no-repeat;
width:128px;
height:150px;
}
 #menu
{
float:left;
width:92%
}
nav ul
{
float:right;
list-style:none;
padding:0;
margin-right:10%;

}
nav li
{
float:left;
margin:0 1em;
color:#605C5D;
font-size:20px;


}
#login
{
float:right;
margin-right:4%;
width:auto;
margin-top:-4%;
}

#container
{

    position: relative;
 margin-top:50px;

background-color:#7F00FF;

}

我的 html

<!DOCTYPE HTML>
<html>
<title>Online Education</title>
<head>
<meta charset="UTF-8">
<meta name ="viewport" content="width=device-width,intial-scale=1.0"/>
<link rel="stylesheet" href="Css/reset.css" type="text/css" media="screen"/>
<link rel="stylesheet"  href="Css/style.css" type="text/css" media="screen"/>
<script src="Js/modernizr.js"></script>
<script src="Js/respond.min.js"></script>
</head>
<body>
<div>
<header>
<div id="menu">
<h1>

<div id="logo">

</div>

<nav>
<ul>
<li>
HOW IT WORKS
</li>
<li>
COURSES
</li>
<li>
SCHOOLS
</li>
<li>
REGISTER
</li>


</ul>
</nav>



</h1>
</div>
<div id="login">
<input type="button" value="login" id="loginbtn"/>
</div>
</header>
</div>
<div id="container">
<section  >
<div >

</div>
</section>
</div>
</body>
<html>
4

1 回答 1

1

为您的容器添加此 css...删除容器的其他 css 只需粘贴即可

background-color: #7F00FF;
float: left;
margin-top: 50px;
position: relative;
于 2013-08-21T08:40:18.403 回答