JSfiddle 应该解释一下:http: //jsfiddle.net/UMW26/
或者
就像标题说的那样,如何防止固定导航栏在单击链接或通过 url 地址访问后覆盖文本/标题,这将跳转到它。
这是我使用的示例代码:
<!DOCTYPE html>
<style type="text/css">
body { margin: 0; }
#content { height: 1500px;margin-top: 20px;background-color:skyblue; }
#fix-nav-bar { position: fixed; width:100%; top:0; text-align:center; background-color: pink; }
#content-title { margin-top: 250px;font-weight:bold;font-size:16pt; }
</style>
<div id="fix-nav-bar">
fixed navigation bar
</div>
<div id="content">
<a href="#content-title">Click here to jump to Title:</a>
<div id="content-title">Sample Content Title/Name</div>
How do I prevent fixed navigation bar from covering title after clicking "<b>Click here to jump to Title</b>" but just keep it slightly above it?
</div>