开发者

DIV resizing in JS : can this be done before the page is displayed?

开发者 https://www.devze.com 2023-03-16 20:32 出处:网络
In my page I give a certain size to a DIV with jQuery, based on the size of the last tweet that I retrieve through PHP.

In my page I give a certain size to a DIV with jQuery, based on the size of the last tweet that I retrieve through PHP.

Problem : I need to use jQuery(window).bind("load", function() in order for jQuery to "see" the size of the tweet, but then, I can see the resizing (perfomed my jQuery) in front of 开发者_如何学Gomy eyes and I dislike it. I want the page to appear in its final state.

Is that possible ?


You have two options. 1) Start off with your tweet element hidden, then show/fade it in when everything is loaded.

2) My preferred solution is to call the $.blockUI() plugin as soon possible, and then $.unblockUI when everything has loaded. The blockUI plugin also has a facility for blocking only certain elements rather than the whole page, there is a demo here


You can always let it render at a top margin of -1000px and then pop it back down, or perhaps z-index it underneath something else. Some browsers have problems "seeing" hidden divs while some can do it, but it's unrelible so best bet is to render it outside the canvas.

0

精彩评论

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