开发者

positioning image with javascript

I've got a background image which I want to put on a selector #page_wrap, but I would like to overlap that background image on another div which sits above it, by about 20 pixels.

I was wondering how you do this with javascript?

As its a CMS I'm unable to split the image into 2 and use a background image for the div above it so thought with javascript I could accomplish t开发者_Go百科his, but I've forgotten how to do it.

Hope you can help,

Kind Regards


"I would like to overlap that background image on another div which sits above it, by about 20 pixels."

Demo: http://jsfiddle.net/wdm954/yADGy/

If you have the option to just edit the CSS I would add this...

#page_wrap {
    margin-top: -20px;
    position: relative;
    z-index: 1;
}

If you have to use jQuery then try this...

$('#page_wrap').css({
    'margin-top' : '-20px',
    'position' : 'relative',
    'z-index' : '1'
});

If this isn't what you're trying to do please elaborate some.


Using jquery?

$("#page_wrap").css("margin-top","-20px");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜