2013-08-24 204 views
2

我使用從右側到左側的滾動滾動。下面的代碼工作正常。但它的滾動並不順暢。 「懸停在我身上停止」的內容閃爍或閃爍。我需要爲下面的選取框100%平滑滾動。請幫幫我。是否有可能沒有JavaScript?選框不平滑滾動,需要100%平滑滾動選框

<marquee behavior='scroll' direction='left' scrollamount='3' onmouseover='this.stop()' onmouseout='this.start()'>Hover on me to stop</marquee> 
+0

好,然後給我用JS的解決方案。 – user2644743

+2

選取框標記已被棄用。請不要使用。看到這個解決方案:http://stackoverflow.com/a/2227838/1121982 – hallaji

+2

你會付多少錢?如果你不付錢,我明白你想自己做。只是[谷歌](http://www.google.com)「javascript選取框替代」 – Itay

回答

-1

有點遲到了..

有角指令此:https://github.com/davidtran/angular-marquee。你不要碰任何JS - 只需添加該指令的標籤,你就大功告成

<div angular-marquee></div> 

而且它不落人後的「過時標籤」的說法,依託現代化的解決方案

2

如果您希望嘗試使用純CSS,那麼這是最簡單的方法。儘管您需要檢查對舊版瀏覽器的支持,並添加了供應商前綴。

.marquee-parent { 
 
    position: relative; 
 
    width: 100%; 
 
    overflow: hidden; 
 
    height: 30px; 
 
} 
 
.marquee-child { 
 
    display: block; 
 
    width: 147px; 
 
    /* width of your text div */ 
 
    height: 30px; 
 
    /* height of your text div */ 
 
    position: absolute; 
 
    animation: marquee 5s linear infinite; /* change 5s value to your desired speed */ 
 
} 
 
.marquee-child:hover { 
 
    animation-play-state: paused; 
 
    cursor: pointer; 
 
} 
 
@keyframes marquee { 
 
    0% { 
 
    left: 100%; 
 
    } 
 
    100% { 
 
    left: -147px /* same as your text width */ 
 
    } 
 
}
<div class="marquee-parent"> 
 
    <div class="marquee-child"> 
 
    Hover on me to stop 
 
    </div> 
 
</div>

+0

你可以沒有差距嗎? –