2011-07-09 19 views
0
<div id="par"> 
    <div id="item11"></div> 
    <div id="item12"></div> 
    <div id="item13"></div> 
    <div id="item14"></div> 
    .... 
</div> 

私はdiv#pardiv#itemXX要素の自動スクロールをアップしたいスクロールアップを繰り返します。また、毎回1つのdivに移動したい。要素自動作成し、

私は<marquee>タグを使用できますが、廃止されているので、別の方法があるのでしょうか?

注意:div#itemXXの高さは固定されていません。

更新日: 「div#itemXX」の移動を1回ずつ実行します。スライドショーのように、毎回1つのdivを表示しますが、現在のdivの高さがビューポートより大きい場合、スクロールの終了時に次のdiv(スライド)が上に移動する必要があります。

答えて

1
(function(){ 
var top=0; 
var par = document.getElementById('par') 
var scroll = function() { 
    top++; 
    if(top>=par.firstElementChild.offsetHeight) 
    { 
    //first element is out of sight, so move to the end of the list 
    top=0; 
    par.firstElementChild.style.marginTop='';//reset to zero 
    par.appendChild(par.firstElementChild); 
    } 
    else 
    { 
    //move the first element 'top' px up 
    par.firstElementChild.style.marginTop='-'+top+'px'; 
    } 
    setTimeout(scroll, 100);//repeat after 100ms 
} 
scroll(); 
})() 

jsbin:http://jsbin.com/onohan/3/

+0

おかげで、私は私のポストをupate、私はさらに効果が欲しいです。 – hguser

+2

@hguser:スクリプトを調整してみます。あなた自身も何かをしなければならない、これは無料のコーディングサービスではありません。または、あなたのためにそれをするために誰かに支払う。 –

+0

ifとelseの中でsetTimeoutを動かし、if内部でタイムアウト値を大きくします。 – Gerben

関連する問題