All divs change position horizontally if you make the browser window larger. Is there way to prevent this happening? Any help greatly appreciated.
Thank开发者_JAVA百科s
I see you're using jQuery on the page, why don't you try the jQuery UI position utility:
http://jqueryui.com/demos/position/
This allows you to position any element relative to another element.
setPositionPopUp: function ($posObj, $dlg, topOff, leftOff) {
var dl = $dlg.get(0);
if ($dlg.length == 0) {
return;
}
if (topOff == null)
topOff = 20;
if (leftOff == null)
leftOff = 20;
var v = $posObj.offset();
dl.style.position = "absolute";
dl.style.top = (v.top + topOff) + 'px';
dl.style.left = (v.left + leftOff) + 'px';
dl.style.zIndex = "10000";
$dlg.fadeIn("slow");
}
I have used the above code to achieve what you want. If you dont want to include the whole jquery ui file.
You can call it like follows:
setPositionPopup($('.colors_box'), $('img'));
Choose your selectors correctly obviously.
精彩评论