开发者

Why position of div is different when browser is resized to a certain dimension?

开发者 https://www.devze.com 2023-02-15 18:54 出处:网络
See working example at http://jsfiddle.net/xqwqH.I have a green div inside a red div. Green div is positioned usin开发者_JS百科g jQuery postion().If I resize the browser to where the bottom edge is in

See working example at http://jsfiddle.net/xqwqH. I have a green div inside a red div. Green div is positioned usin开发者_JS百科g jQuery postion(). If I resize the browser to where the bottom edge is inside the green square and refresh the page (see example below), the green square moves to a different location. I thought it was a bug in the browser but when it worked the same way in IE8, FF and Chrome, it seems this behavior is normal.

Why does the div change position when browser window was resized in that manner?

Why position of div is different when browser is resized to a certain dimension?


Try adding collision: "none" to the list of arguments for position. i.e.

$(document).ready(function() {
         $('#div1').position({
             my: "left top",
             at: "left top",
             of: $('#wrapper'),
             offset: "40 10",
             collision: "none"
         });
 });

See the jquery documentation:

http://docs.jquery.com/UI/Position

0

精彩评论

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