Html 为什么选框标签在谷歌浏览器中不起作用。?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16392486/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
why marquee tag not working in google chrome.?
提问by Anand Jaju
I want to insert an image into marquee tag.
我想在选取框标签中插入图像。
I have written following code:
我写了以下代码:
<marquee scrollamount="4" behavior="alternate" direction="right" width="300"><img width="180px" style="padding-left:30px;opacity:0.7" src="img/cloud3.png"></marquee>
Its working fine in firefox and IE but not working in chrome. What is the problem.? Please reply as early as possible. Thanks in advance.
它在 Firefox 和 IE 中工作正常,但在 chrome 中不起作用。问题是什么。?请尽快回复。提前致谢。
回答by feesh
Because the marquee
tag is a crime against nature. And it's no longer supported in newer versions of Chrome.
因为marquee
标签是对自然的犯罪。较新版本的 Chrome 不再支持它。
回答by zellio
The marquee
is not supported in modern html. Chrome dropped support for it a while ago. You need to implement this via CSS3 or Javascript.
在marquee
没有现代的HTML支持。Chrome 不久前放弃了对它的支持。您需要通过 CSS3 或 Javascript 来实现。
Further W3C states that it is non standardand should not be used.
W3C 进一步声明它是非标准的,不应使用。
回答by Jukka K. Korpela
The marquee
element has varying implementations, partly because there has been no published specification for it. In HTML5, the element is being defined exactly, and HTML5 drafts requiresupport to marquee
as defined there. (The drafts also declare it “obsolete” and “nonconforming”, but these are just what they say to authors; the requirements on implementationsare different.) However, there are still limitations and differences in support, see e.g. MDN on marquee
.
该marquee
元素有不同的实现,部分原因是没有发布它的规范。在 HTML5 中,元素被精确定义,并且 HTML5 草稿需要支持在marquee
那里定义。(草案还声明它“过时”和“不符合”,但这只是他们对作者说的;对实现的要求不同。)但是,仍然存在支持方面的限制和差异,例如参见MDN onmarquee
。
In this case, it does not seem to be the image but the attribute behavior="alternate"
that causes the problem. If you remove it, the image will move on Chrome, too.
在这种情况下,似乎不是图像而是behavior="alternate"
导致问题的属性。如果您将其删除,该图像也会在 Chrome 上移动。
This is apparently implementation bugrather than lack of support. Inspecting the DOM in Chrome shows that the behavior
property has the value alternate
as specified, but it just does not work. If you add a border to the marquee
element in CSS, the image starts moving, alternatingly, but just a few pixels right and left.
这显然是实现错误而不是缺乏支持。在 Chrome 中检查 DOM 显示该behavior
属性具有alternate
指定的值,但它不起作用。如果marquee
在 CSS 中为元素添加边框,图像将开始交替移动,但只是左右移动几个像素。
If you really alternating direction, it is probably best to use some other technique instead of marquee
. For example, a simple moving image can be implemented using JavaScript so that the position is changed in a loop, using a timer, and then you can easily implement alternating direction, too. Alternatively, possibly simpler but not as robustly (due to limited browser support), you can use CSS3 animations.
如果您真的要交替方向,最好使用其他一些技术来代替marquee
。例如,可以使用 JavaScript 实现简单的运动图像,使用定时器循环更改位置,然后您也可以轻松实现交替方向。或者,可能更简单但不那么健壮(由于浏览器支持有限),您可以使用 CSS3 动画。
回答by Priya Sunanthan
HTML:
HTML:
<div id="cloud">image</div>
CSS:
CSS:
#cloud{
width:180px;
padding-left:30px;
opacity:0.7;
animation:slide 10s infinite;
-moz-animation:slide 10s infinite;//Firefox
-webkit-animation:slide 10s infinite;//chrome and safari
-o-animation: slide 10s infinite;//Opera
}
@keyframes slide{
0% {-transform: translate(0px, 0px); }
100% {-transform: translate(500px,0px); }
}
@-moz-keyframes spin{
0% {-moz-transform: translate(0px, 0px); }
100% {-moz-transform: translate(500px, 0px); }
}
@-webkit-keyframes slide{
0% {-webkit-transform: translate(0px, 0px); }
100% { -webkit-transform: translate(500px,0px); }
}
@-o-keyframes slide{
0% {-o-transform: translate(0px, 0px); }
100% {-o-transform: translate(500px, 0px); }
}
Here is the fiddle:
这是小提琴:
Replace the text with the image.
用图像替换文本。
回答by Mudassir Hasan
Marquee has been deprecated so will show unspecified behaviour on different browsers.
Marquee 已被弃用,因此将在不同浏览器上显示未指定的行为。