user961239
user961239

Reputation: 87

Positioning of a pop up

All divs change position horizontally if you make the browser window larger. Is there way to prevent this happening? Any help greatly appreciated.

Thanks

Upvotes: 0

Views: 106

Answers (2)

MoXplod
MoXplod

Reputation: 3852

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.

Upvotes: 1

swatkins
swatkins

Reputation: 13630

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.

Upvotes: 1

Related Questions