2013-02-28 70 views
3

我在滾動標記中有一些文字。html 5在w3c驗證中的滾動標記錯誤

<marquee direction="left" scrollamount="4"> 
Test Test Test Test Test 
</marquee> 

我使用HTML 5和CSS 3,當我在W3C驗證檢查我的HTML,它顯示了以下錯誤。

Element marquee not allowed as child of element div in this context. (Suppressing further errors from this subtree.) 

     <marquee direction="left" scrollamount="4"> 

如何解決這個問題?

+1

您正在使用HTML5和CSS3,以及'marquee'該出去了15年前的時尚? ;) – alex 2013-02-28 06:14:50

+0

marquee ?? ...在html5中已棄用!使用CSS3動畫獲得相同的結果! – Alfr3d 2013-02-28 06:19:22

+0

感謝您的建議。 – lifeline 2013-02-28 06:47:10

回答

6

字幕標記不是HTML5(是不是HTML可言,但是從1995年微軟專有標記)

,您可以:

  • 使用JavaScript動畫的文字
  • 使用CSS動畫(not fully browser compatible
  • 使用css3 marquee(不完全與瀏覽器兼容)
  • 使用字幕並忽略W3C警告(字幕是全瀏覽器兼容的,ev恩在iOS的Safari瀏覽器!)
  • 不使用字幕效果(這是醜陋的)

小心W3C驗證,它並不總是知道所有的W3C規範!

0

使用CSS3選框,而不是它

HTML

<p class="marquee"><span>This is your sample text.</span></p> 

CSS

/* Make it a marquee */ 
.marquee { 
    width: 450px; 
    margin: 0 auto; 
    white-space: nowrap; 
    overflow: hidden; 
    box-sizing: border-box; 
} 

.marquee span { 
    display: inline-block; 
    padding-left: 100%; 
    text-indent: 0; 
    animation: marquee 15s linear infinite; 
} 

.marquee span:hover { 
    animation-play-state: paused 
} 

/* Make it move */ 
@keyframes marquee { 
    0% { transform: translate(0, 0); } 
    100% { transform: translate(-100%, 0); } 
}