html uso tag / reemplazo

StackOverflow https://stackoverflow.com/questions/4423618

Pregunta

Yo sé que las etiquetas <marquee> son malos.
Si es tan malo tener desplazar el texto, a continuación, utilizando JS para obtener el mismo efecto no significa que sea mejor, ¿verdad?

Y supongo que decidió pasar un buen desplazamiento de texto (jadeo) , ¿hay algún tipo de CSS (3?) O HTML (5?) Manera de hacer esto que es técnicamente correcto (es decir, no obsoleta)?

Si no hay una solución CSS / HTML, debería usar:

  • Javascript, que será más pesado para descarga y puede ser desactivado (es que un profesional o una estafa?), Pero me da la ventaja de estar W3C correcta y válida y no obsoleta e inteligente,

o debería utilizar

  • el <marquee> odiaba etiqueta ( ), que es de peso ligero (19 bytes!), Totalmente compatible con todos los navegadores en todos los modos de representación y todos doctypes (aunque no debería ser), pero está en desuso ?

Gracias.

P.S. Creo que una barra de noticias es un uso válido para la carpa estilo
P.P.S. Si alguien me dice que si yo no quiero una solución Javascript pesada que debería usar jQuery porque es ligero, voy a disparar en los comentarios

Editar:. Estoy agregando etiqueta jQuery ya que parece ser la mejor manera de conseguir la atención de una gran cantidad de expertos sobre cuestiones JS, y no tiene nada que ver aquí

¿Fue útil?

Solución

It is not the effect that is bad. The problem with marquee, blink and font tags is that they convey presentation not structure of your content.

Otros consejos

CSS3 has support for marquee, but it is only supported in a few browsers (Safari and Chrome are the only one, to my knowledge)

http://www.w3.org/TR/css3-marquee/

There are several JQuery plugins that accomplish it, but they come at the expense of loading JQuery (26Kb, heavier than the HTML only solution, but not what I would call heavy)

http://plugins.jquery.com/plugin-tags/marquee

Of course you can easily do it yourself without JQuery, but looking at those plugins may give you ideas.

Another option to consider is to do a small Flash animation.

If you're sure that it works on all platforms you're aiming for, and you don't care what w3c says you can certainly use the marquee tag. There is no way that you can find a JavaScript solution that works in less than 14 bytes.

The only unfortunate thing is that the reason all these browsers support all these deprecated elements that are -in this case- not even part of any HTML standard, is because of all these people using these elements and start whining when a new version doesn't support their 1982 compliant website anymore.

So please go ahead and use marquee as long as it works for you, but please don't complain if you site stops working in a newer browser.

Here's the code that implements the marquee element in Firefox, it's basically doing it in JavaScript anyway so you could always just adapt that code and use it directly in all browsers.

The code can be hacked around so that marquee can be implemented on any element in Firefox, applied through CSS and XBL bindings (Firefox only example). The equivalent in IE would be behaviours, and you could use the CSS3 in Safari/Chrome as nico suggested and you would be keeping the presentational stuff out of your markup, but only you can know if it's worth the effort.

I've been looking for the most efficient and cross-browser supported marquee implementation. For whatever reason, even the webkit CSS marquee implementation is glitchy.

The common approach is to use timer (or jQuery animate implementation) to adjust the CSS margin property of the element. This is too glitchy and very inefficient. I came up with implementation that utilises CSS3 transitions for browsers that support it and otherwise animate the scrollLeft property of the containing element. It is an experimental implementation, though it works well with IE7+. Other people might find it useful as well, https://github.com/gajus/marquee (demo https://dev.anuary.com/60244f3a-b8b2-5678-bce5-f7e8742f0c69/).

Recently, i had to do this effect for a client and i've used this plugin which is very easy to use :

jQuery Marquee plugin on github

jQuery Marquee on plugins.jquery.com

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top