why marquee tag not working in google chrome.?

前端 未结 6 1654
心在旅途
心在旅途 2020-12-11 04:18

I want to insert an image into marquee tag.

I have written following code:



        
      
      
      
6条回答
  •  误落风尘
    2020-12-11 05:12

    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 require support 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 implementations are different.) However, there are still limitations and differences in support, see e.g. MDN on marquee.

    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.

    This is apparently implementation bug rather 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.

    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.

提交回复
热议问题