javascript - Jquery backstretch inside div? - Stack Overflow

I am trying to achive a fullscreen background image inside a div using JQuery.I am using the Backstretc

I am trying to achive a fullscreen background image inside a div using JQuery.

I am using the Backstretch plugin, which works fine however it binds the image to the body tag.

I am looking to apply this to a div with the id of home_middle_bg, any ideas?

Thanks

I am trying to achive a fullscreen background image inside a div using JQuery.

I am using the Backstretch plugin, which works fine however it binds the image to the body tag.

I am looking to apply this to a div with the id of home_middle_bg, any ideas?

Thanks

Share Improve this question asked Jul 18, 2011 at 15:57 shovelnoseshovelnose 231 silver badge3 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 2

I added a new settings option that defaults to body if undefined. So the suggestion from above would look like so:

 if($(settings.targetObject + ' #backstretch').length == 0) {
      $(settings.targetObject).append(container);
 }

Actually the image is binded to a div and that is prepended to the body: you could modify it by hand by replacing (line 69 of the plugin):

            if($("body #backstretch").length == 0) {
                $("body").prepend(container);
            }

with

            if($("#home_middle_bg #backstretch").length == 0) {
                $("body").prepend(container);
            }

If you still want to use that plugin, you'd need to modify it around here (replace "body" with what you want) : https://github./srobbin/jquery-backstretch/blob/fcb8ee843b4d88a5081668ec615afd6a57da8242/jquery.backstretch.js#L72

For me the jumping cause in the jquery.backstretch.js plugin was solved by updating the plugin code:

Instead of (default)

t.backstretch=function(i,e){return t("body").backstretch(i,e).data("backstretch")}

for me it worked when referring backstretch to a different container:

t.backstretch=function(i,e){return t("#header").backstretch(i,e).data("backstretch")}....

Regards, ventilator5000

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745331082a4622879.html

相关推荐

  • javascript - Jquery backstretch inside div? - Stack Overflow

    I am trying to achive a fullscreen background image inside a div using JQuery.I am using the Backstretc

    6小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信