我的字幕标签中有一些文字。
<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">
如何解决这个问题?
Marquee 标签不是 html5(根本不是 html,而是 1995 年的 Microsoft 专有标签)
你可以:
当心 W3C 验证器:它并不总是知道所有 W3C 规范!
marquee 标签在 HTML5 中已被废弃,但在 CSS3 中又重新出现(请参阅 http://www.w3.org/TR/css3-marquee/)。
使用CSS3 Marquee代替它
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); }
}