2013-03-03 37 views
0

固定在我的单页网站的屏幕上方地狱啊,我有浮动菜单上的修改。当我点击菜单项,页面缓缓使用jQuery向下滚动到相应的部分。我对屏幕的顶部固定的菜单下面的代码:浮动的CSS仅菜单 - 如何第2节

<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> 
... 

的代码是OK,一切工作正常。我需要做的事情是修改菜单时,它是在第2节,只有SECTION3,并添加“UP”按钮。

当我加载页面,我不需要“UP”按钮,因为这是不可能上去,它的混乱在那里,所以我需要它只有当我向下滚动。仅用CSS(1,2,3)可能吗?谢谢!

+0

你可以提供一个小提琴?你的代码是部分的,你没有使用一半定义的类。 UP按钮应放置在哪里?菜单里面? – 2013-03-04 10:01:12

回答

1

不可能的,因为你必须获取垂直文档的偏移知道,如果用户是在页面的顶部,或者已经向下滚动。需要垂直偏移来决定是否显示向上按钮。

有一种方法用JS做到这一点,但如果你问一个只CSS的解决方案,我给你一个坏消息已:P