0

无论如何我可以让滚动的绿色 div 将黑色导航推到页面上而不是滚动到它的顶部?

这是我的示例,向下滚动页面,横幅将淡出并滚动:

http://www.mharrisweb.co.uk/

jQuery 补充说:

jQuery(function($) {

  function scrollBanner() {
    //Get the scoll position of the page
    scrollPos = jQuery(this).scrollTop();

    //Scroll and fade out the banner text
    jQuery('.hero-unit').css({
      'margin-top' : -(scrollPos/3)+"px",
      'opacity' : 1-(scrollPos/300)
    });

    //Scroll the background of the banner
    jQuery('.fade').css({
      'background-position' : 'center ' + (-scrollPos/8)+"px"
    });    
  }

  jQuery(window).scroll(function() {        
    scrollBanner();        
  });`

我想要和这个网站一样的效果:

http://themetrust.com/demos/hero/

4

1 回答 1

0

也许您也可以添加div.navbar-fixed-top滚动行为?与.hero-unit. 所以他们会以相同的“速度”移动

于 2013-02-06T11:18:33.353 回答