我正在尝试创建一个标题固定在顶部但始终居中的网站(除非屏幕太小,我希望它位于左侧并在右侧裁剪),然后我希望我的内容向上滚动在页眉下方,以使页眉保持原样,但您可以滚动浏览页面底部。这是我现在拥有的代码:
<body>
<div id="header_img">
<span class="class1">
<a href="index.html"><h2>HEATHER</h2></a></span>
<p class="style5">
419.953.5098<br>
<span class="class2">
<a href ="mailto:obringhm@mail.uc.edu">obringhm@mail.uc.edu</a></span></p>
<table>
<tr>
<td><a href="b5_photo_portrait.html">portraits</a></td>
<td><a href="b5_photo_object.html">objects</a></td>
<td>records
</td>
</tr>
</table>
</div>
<div id="header_img2" style="scroll:auto">
<img class="project14"src="images/image17.jpg">
<img class="project15" src="images/image16.jpg">
<img class="project16" src="images/image20.jpg">
<h3>Portrait Series</h3>
<p>This project is an exploration of composition within a photograph and
the studying of correct value tones in a picture.
<br><br>
Completed: December 2011<br>
Tools: Film Photography
<br></p>
</div>
</body>
和CSS:
#header_img {
height: 180px;
background: #E2E2E2;
width: 998px;
position: fixed;
top: -25px;
margin: 0 auto;
z-index: 11;
box-shadow: 0 6px 10px -10px #888;
}
#header_img2 {
height: 800px;
background: E2E2E2;
width: 998px;
position: relative;
top: 200;
z-index: 10;
}
现在,我的内容在标题下方滚动,但标题固定在左侧!