2013-11-01 2 views
1

애니메이션을 사용하여 HTML에서 일부를 변경하는 경우 jquery는 '텍스트를 바꾸는 대신 텍스트를'이동 '/ 이동합니다. 여기Jquery 움직이는 텍스트

확인 : http://jsfiddle.net/x2VYn/

function cycleIntro() { 
     var whoArr = ["colleagues", "girlfriend", "homies", "nemesis", "lover", "dad", "mom", "brother", "sister", "enemies", "friends", "classmates", "best friend", "imaginary friend", "grandma'"]; 
     var whatArr = ["pool", "backgammon", "dart", "chess", "ping pong", "bob", "headsup poker", "ludo", "yatzy", "foosball", "tennis", "street basket", "golf", "water polo"]; 

     var whotxt = whoArr[Math.floor(Math.random() * whoArr.length)]; 
     while ($("#intro #who").html() == whotxt) { 
      whotxt = whoArr[Math.floor(Math.random() * whoArr.length)]; 
     } 
     var whattxt = whatArr[Math.floor(Math.random() * whatArr.length)]; 
     while ($("#intro #what").html() == whattxt) { 
      whattxt = whatArr[Math.floor(Math.random() * whatArr.length)]; 
     } 
     $("#intro #who").animate({ width: "toggle" }, 200, function() { 
      $("#intro #who").html(whotxt).animate({ width: "toggle" }, 300, function() { 
       $("#intro #what").delay(50).animate({ width: "toggle" }, 200, function() { 
        $("#intro #what").html(whattxt).animate({ width: "toggle" }, 300, function() { 
         setTimeout(cycleIntro, 1500); 
        }); 
       }); 
      }); 
     }); 
    } 
    setTimeout(cycleIntro, 1500); 

사람이를 조정하는 방법을 알고 있나요?

답변

1

조작중인 범위의 vertical-align 속성을 bottom으로 설정하면 문제가 해결됩니다. 나는 바이올린 here을 업데이트했습니다.

+0

높이를 사용해도 문제가 해결되지 않습니다. '폭'은 내가 바라는 방식입니다. 그러나 오류는 단어를 토글 할 때마다 발생합니다. 텍스트를 이동/이동하는 여백/여백을 삽입하는 것처럼 보입니다. – 2mas

+0

죄송합니다! 나는 그 질문을 오해했다. 내 업데이트 된 답변을 참조하십시오. – Csarsam

+0

굉장! 확실히 트릭을! 고마워! – 2mas

관련 문제