开发者

jQuery UI Position : When window resize

开发者 https://www.devze.com 2023-03-12 23:39 出处:网络
http://jsfiddle.net/jqrmh/ $(\".one\").position({ \"my\": \"right top\", \"at\": \"right top\", \"of\": $(\".main\"),

http://jsfiddle.net/jqrmh/

$(".one").position({
        "my": "right top",
        "at": "right top",
        "of": $(".main"),
});

I need to my box still stay right-top when i resize window... I try to use "collision": "fit fit" ..... it not work

http://jsfiddle.net/jqrmh/

开发者_如何学运维

(http://wiki.jqueryui.com/w/page/12138026/Position)


You could just re-position on resize:

http://jsfiddle.net/jqrmh/4/

function moveit() {
    $(".one").position({
        "my": "right top",
        "at": "right top",
        "of": $(".main"),
        "collision": "fit fit"
    });
}

$(window).resize(function(){
   moveit(); 
});

moveit();

Alternatively, assuming there's not some other reason you can't just use css:

Just set the parent positon:relative and set the child position:absolute. Then you can just set the child top:0; right:0.

http://jsfiddle.net/jqrmh/5/

0

精彩评论

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