嗨,我有一个 4 页的网站,分为以下页面:
- 指数
- 关于
- 我的工作
- 接触
在索引页面上,我nivoslider
的高度为 350 像素。
在大约 7 个联系页面上,我还有一个高度为 350 像素的 div。
在我的工作页面上,我有一个没有高度的 div,因此它可以随内容垂直扩展。
出于某种原因,如果我添加的内容会使我的工作页面 div 超过 350 像素,它会导致主容器 div 稍微向左移动。每个页面上的容器都是相同的,并且只有导致它的内容。我尝试过文本、图像和其他 div,它们都会导致相同的问题。
的HTML:
body {
background-color: #efe0b5;
background-image: url(images/stripe.png);
background-repeat: repeat-x;
background-position: left top;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="logo">
<img src="images/logo.png" width="145" height="40" alt="Joanne Stansfield Logo" />
</div>
<div id="nav">
<ul class="nav-bar">
<li class="home"><a href="index.html">Home</a></li>
<li class="about"><a href="about.html">About Us</a></li>
<li class="mywork"><a href="mywork.html">My Work</a></li>
<li class="getintouch"><a href="getintouch.html">Get in Touch</a></li>
</ul>
</div>
</div>
<div id="main4">
<img src="images/mywork-header.png" width="920" height="70" alt="About Me" />
</div>
<div id="footer"></div>
</div>
</div>
</body>
</html>
CSS
* {
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
}
@font-face {
font-family: 'CoopLightRegular';
src: url(/cooplight-webfont.eot) format('embedded-opentype'),
url(/cooplight-webfont.eot?#iefix) format('embedded-opentype'),
url(/cooplight-webfont.woff) format('woff'),
url(/cooplight-webfont.ttf) format('truetype'),
url(/cooplight-webfont.svg#CoopLightRegular) format('svg');
font-weight: normal;
font-style: normal;
}
#wrapper {
width: 960px;
padding: 0px;
margin-top: 0;
margin-right: auto;
margin-bottom: 0;
margin-left: auto;
}
#wrapper #header {
height: 200px;
width: 100%;
margin-top: 25px;
float: left;
}
#wrapper #header #logo {
float: left;
height: 200px;
width: 560px;
}
#wrapper #header #logo img {
height: 40px;
width: 145px;
margin-top: 60px;
}
#wrapper #header #nav {
position:relative;
width: 400px;
height: 200px;
float:right;
overflow: hidden;
}
#wrapper #header .nav-bar li {
position: absolute;
list-style: none;
}
#wrapper #header .nav-bar li a {
display: block;
width: 200px;
height: 200px;
text-indent: -9999px;
}
#wrapper #nav .nav-bar li.home { left: 70px; top: -30px; }
#wrapper #nav .nav-bar li.home a { background:url(../images/home.png) no-repeat; }
#wrapper #nav .nav-bar li.home a:hover { background:url(../images/home.png) no-repeat 0 -200px; }
#wrapper #nav .nav-bar li.about { left: 130px; top: -30px;}
#wrapper #nav .nav-bar li.about a { background:url(../images/aboutme.png) no-repeat; }
#wrapper #nav .nav-bar li.about a:hover { background:url(../images/aboutme.png) no-repeat 0 -200px; }
#wrapper #nav .nav-bar li.mywork { left: 190px; top: -30px; }
#wrapper #nav .nav-bar li.mywork a { background:url(../images/mywork.png) no-repeat; }
#wrapper #nav .nav-bar li.mywork a:hover { background:url(../images/mywork.png) no-repeat 0 -200px; }
#wrapper #nav .nav-bar li.getintouch { left: 250px; top: -30px; }
#wrapper #nav .nav-bar li.getintouch a { background:url(../images/getintouch.png) no-repeat; }
#wrapper #nav .nav-bar li.getintouch a:hover { background:url(../images/getintouch.png) no-repeat 0 -200px; }
#wrapper #main {
background-color: #FFF;
width: 100%;
height: 350px;
float: left;
}
#wrapper #main3 {
background-color
: #FFF;
width: 100%;
height: 350px;
float: left;
}
#container #wrapper #main3 #left {
background-color: #999;
float: left;
height: 200px;
width: 440px;
margin-right: 10px;
margin-left: 10px;
margin-top: 30px;
}
#container #wrapper #main3 #right {
background-color: #666;
float: right;
height: 200px;
width: 440px;
margin-right: 10px;
margin-left: 10px;
margin-top: 30px;
}
#container #wrapper #main3 #form {
background-color: #CCC;
height: 200px;
width: 920px;
margin-top: 30px;
}
#wrapper #main4 {
background-color: #FFF;
width: 100%;
min-height: 350px;
float:left;
}
#container #wrapper #main4 .gallery {
background-color: #03C;
height: 200px;
width: 960px;
margin-top: 30px;
margin-bottom: 30px;
float: left;
}
#wrapper .title {
height: 70px;
width: 100%;
float: left;
}
.nivoSlider {
position:relative;
width:960px; /* Change this to your images width */
height:350px; /* Change this to your images height */
background:url(images/loading.gif) no-repeat 50% 50%;
}
.nivoSlider img {
position:absolute;
top:0px;
left:0px;
display:none;
}
.nivoSlider a {
border:0;
display:block;
}
#wrapper #footer {
height: 70px;
width: 960px;
font-family: Trebuchet MS, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #999;
text-align: center;
line-height: 20px;
margin-top: 50px;
margin-left: auto;
margin-right: auto;
float: left;
}
#wrapper #footer img {
height: 20px;
width: 55px;
}