天哪,我在单页网站的屏幕顶部固定了浮动菜单。当我单击菜单项时,页面会慢慢向下滚动到使用 jquery 的相应部分。我在屏幕顶部有固定菜单的代码:
<style>
.fixed_elements{ position:fixed; top:100px; }
#top-floating-bar{ background: none repeat scroll 0 0 #2D2D2D; height: 35px; position: fixed; top: 0; width: 100%; z-index: 100; }
ul{ padding: 0; margin: 0; }
.fixed-bar-buttons{ float: left;color: #fff; }
.fixed-bar-buttons ul { height: 25px; padding-right: 10px; }
.fixed-bar-buttons ul li{ display: block; float: left; font-family: sans-serif; font-size: 14px; font-weight: bold; height: 25px; padding-left: 10px; padding-right: 10px; padding-top: 10px; }
.fixed-bar-buttons ul li:hover{ background-color: #605F5F; }
#content-panel{ float: left;margin-top: 40px; }
</style>
</head>
<body>
<div id="top-floating-bar">
<div class="fixed-bar-buttons">
<ul class="nav">
<li><a href="#section2">REFERENCIE</a></li>
<li><a href="#section3">KONTAKT</a></li>
</ul>
</div>
</div>
<div id="section2"> Section2 content</div>
<div id="section3"> Section3 content</div>
...
代码没问题,一切正常。我需要做的是仅在 section2 和 section3 上修改菜单并添加“UP”按钮。
当我加载页面时,我不需要“向上”按钮,因为它不可能向上并且在那里令人困惑,所以我只有向下滚动时才需要它。是否可以仅使用 CSS(1,2,3)?谢谢!