0

我有一个divs页面列表:

<div class="section"><span>Client Information </span>
 <!-- Some fields here -->
</div>
<div class="section"><span>Billing Information </span>
 <!-- Some fields here -->
</div>
<div class="section"><span>Contact Information </span>
 <!-- Some fields here -->
</div>

当用户滚动页面时,我想要Note在浏览器可见部分的顶部。

<div class="note">Note:Please fill all the required fields</div>

例如

  1. 当页面加载并且Client Infomation是可见部分时。注释应出现在客户信息部分的顶部。

  2. 用户向下滚动并且Billing Information是可见部分。注意应该出现在账单信息部分的顶部。

  3. 当用户来到Contact Information部分时,注释应该出现在联系信息部分的顶部。

  4. 如果用户滚动回Client Information部分,注释应该出现在客户信息的顶部。

重要 1:注意 div 应该只出现在部分的顶部,而不是重叠部分字段。

我尝试使用

.note {
 position:fixed;
 width:100%;
 z-index:1080;
}

但这使得note div 重叠部分字段,而我没有。

重要 2:部分 div 位于固定导航栏和徽标下方。这样当第一部分可见时。注意 div 必须放在 logo 和第一部分之间。

4

1 回答 1

1

您需要一些 javascript 来检测窗口是否滚动超出了 note 元素的垂直偏移量,position:fixed然后才应用:

http://jsfiddle.net/bSZpf/

于 2013-10-28T16:32:56.833 回答