【问题标题】:JQuery Waypoints AssistancejQuery Waypoints 协助
【发布时间】:2013-11-15 02:12:52
【问题描述】:

我已经有一段时间没有做网页设计了,有人请我帮忙重现这个效果:http://www.jetsetter.com/destinations/italy?nm=destinations

在别人的帮助下,我已经很接近这里了,但现在我无法改变背景。当我更改背景颜色而不是背景图像时,它可以工作。

有人可以看看我错过了什么吗?

http://jsfiddle.net/pfwwv/28/

$(document).ready(function(){
// attach a waypoint to each div.waypoint element
// the callback is executed every time the user scrolls past 
// see http://imakewebthings.com/jquery-waypoints/#docs
$('.waypoint').waypoint(function(direction){
    // you can use the direction parameter here to check which way the user was     scrolling if you need

    // get the background-image source from the data-src property on the DOM element
    var backgroundSrc = $(this).attr('data-src');

    // now update the CSS for the body
    $(document.body).css({
     'background-image': backgroundSrc
    });
 });

});

【问题讨论】:

    标签: javascript jquery jquery-waypoints


    【解决方案1】:
    $(document.body).css({
        'background-image': 'url(' + backgroundSrc + ')'
    });
    

    Setting background-image using jQuery CSS property

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-07
      • 2014-03-07
      • 1970-01-01
      相关资源
      最近更新 更多