w3c 验证中的 html 5 marquee 标记错误

问题描述 投票:0回答:3

我的字幕标签中有一些文字。

<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"> 

如何解决这个问题?

html w3c-validation marquee
3个回答
7
投票

Marquee 标签不是 html5(根本不是 html,而是 1995 年的 Microsoft 专有标签)

你可以:

  • 使用 javascript 为文本添加动画
  • 使用CSS动画(完全兼容浏览器
  • 使用css3 marquee(不完全浏览器兼容)
  • 使用选取框并忽略 W3C 警告(选取框完全兼容浏览器,即使在 iOS safari 中也是如此!)
  • 不要使用选框效果(它很难看)

当心 W3C 验证器:它并不总是知道所有 W3C 规范!


3
投票

marquee 标签在 HTML5 中已被废弃,但在 CSS3 中又重新出现(请参阅 http://www.w3.org/TR/css3-marquee/)。


1
投票

使用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); }
}
© www.soinside.com 2019 - 2024. All rights reserved.