所以我必须使用HTML和CSS为学校制作一个网页。当我在我的代码预览中查看它时,一切看起来都很好,但是一旦我把它放在我的服务器上,导航栏就不再与我的主体对齐了
这是我的CSS
body {
background-color:#2AA890
}
nav {
margin: auto;
width: 1000px;
}
ul {
padding: 0px;
margin: 45px;
list-style: none;
}
li a:link, li a:visited, li.selected {
float: left;
width: 110px;
line-height: 3em;
background-color: #e9e9e9;
color: #000000;
font-size: 16px;
text-align: center;
text-transform:capitalize;
text-decoration: none;
border-right: 3px #ba0000 solid;
}
li:last-child a {
width: 110px;
border-right: 0px #6e2525 solid;
}
.head {
text-align: left;
padding: 10px 10px 10px 10px
}
.box {
margin-left: 185;
width: 882;
height: 450;
background-color: #acacac;
text-align: left;
padding: 30px 10px 10px 10px
}
.pic1 {
width:900px;
}
.pic1 img {
float:right;
}
.pic1 p {
text-indent: 40px;
line-height: 1.5em;
font-family: sans-serif;
font-size: 17px;
margin-right:400px;
}
.head {
padding: 25px 0px 0px 45px
}
.pic1 p {
padding: 0px 5px 10px 8px
}
.pic1 img{
padding: 30px 20px 20px 10px;
}
这是我的HTML
<! DOCTYPE html>
<html>
<head>
<title>Home</title>
<link rel="stylesheet" type="text/css" href="normalize.css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="Supplies.html">Supplies</a></li>
<li><a href="Step_1.html">Step 1</a></li>
<li><a href="Step_2.html">Step 2</a></li>
<li><a href="Step_3.html">Step 3</a></li>
<li><a href="Step_4.html">Step 4</a></li>
<li><a href="Step_5.html">Step 5</a></li>
<li><a href="Step_6.html">Step 6</a></li>
</ul>
</nav>
<div class="box">
<div class="pic1">
<img src="drew_brophy.jpg" alt="Art" title="Drew Brophy" width="480" height="374">
<div class="head">
<h2>How to Paint a Surfboard</h2>
</div>
<p>The surfboard, one of the most fun toys around. There is just one problem with it. The majority of them are plane white. There is no color and adding some stickers isn't a true way to express yourself! With a little time and some common items from your garage or hardware, you can make it so much better. You don't have to be a great artist or have lots of money to truly make that board your own. This site is a simple guide with some tips and tricks for painting your surfboard. When the waves aren't breaking and your looking at that board in the corner of your room, take some time and change it up! </p>
</div>
</div>
</body>
</html>
答案 0 :(得分:1)
在你的CSS中,请为'box'类添加'px'作为高度,宽度和高度。 对于Nav UL,删除边距。
样品:
margin-left: 185px
width: 882px
height: 450px
答案 1 :(得分:0)
嗨,请查看ul中的边距,并在.box类中设置相等的margin-left。
ul {
margin:45px 0px;
}
.box {
margin-left:0px;
}
在此处查看http://jsfiddle.net/