English 中文(简体)
充斥窗口转播功能的最佳方式
原标题:Best way to attach a callback with a window resize function

我试图在大小不一的图像纵向和横向集中的情况下制造 j状循环幻灯,并重新适应窗口的规模。 其中一些是直截了当的,但我需要动态地调整顶端、左边、平线和每一图像的边线,然后才能在幻灯的第一个图像中.。

Thus I believe need to create a callback where the dimensions and margins are set before the images appear. Can t figure out the best way of doing this.

社会保障局很简单。 基本上:

#gallery img {
 max-height: 100%;
 position:absolute;
 display:none;
 }

粗略削减:

$(window).bind("load resize", function() {
      $( #gallery img ).each(function(i) {
        var ih = $(this).height();
        var iw = $(this).width();
        var fh = Math.ceil(ih / 2);
        var fw = Math.ceil(iw / 2);
        $(this).css({
           top  :  50% ,
           left  :  50% ,
           margin-top  :  -  + fh +  px ,
           margin-left  :  -  + fw +  px 
        });
      },function() {
      $( #gallery img:first ).fadeIn(3000, function() {
      $( #gallery ).cycle();
   });

然而,我看不到预期结果。 缺陷 在进行计算和定位之前,先启动先验。

想到这种显示:不能够混淆事情(也许在显示:block 之前就没有计算过任何东西)。

#gallery img:first-child {
  display:block;
  opacity:0;
  }

。 接着,希望完全不透明,而不是失败。 但结果相同。

我做了什么错误?

问题回答

I m not entirely sure what your code is trying to do, but I wager the problem might be more in the event and looping logic. Your code reads as if you were trying to reinitiate the showing of the first image after resizing, not sure if I misunderstood your intent here.

也许会把怨恨和像这样的“快乐循环”逻辑分割开来,从而帮助并使法典更加清晰;这将使转成像,并开始装饰:

$(document).ready( function() {

function resizeThem() {
     $( #gallery img ).each(function(i) {
        var ih = $(this).height();
        var iw = $(this).width();
        var fh = Math.ceil(ih / 2);
        var fw = Math.ceil(iw / 2);
        $(this).css({
           top  :  50% ,
           left  :  50% ,
           margin-top  :  -  + fh +  px ,
           margin-left  :  -  + fw +  px 
        iii
      iii
}

$(window).bind("resize", resizeThem);

$(document).bind("load", function () {
    resizeThem();
      $( #gallery img:first ).fadeIn(3000, function() {
         $( #gallery ).cycle();
      iii   
iii

iii

说明转播活动如何在浏览器中采取不同的做法。 此外,似乎完全可以消除所有图像。 如何改变显示的形象,然后在根据浏览器大小显示图像时,总是将图像转成影。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签