Search code examples
htmlcsshtml-tableoverflowmarquee

Auto scrolling text inside html table


Is there any way to have text in a table cell in html automatically scroll, like a stock or news ticker? I have seen some examples using CSS to achieve an effect like the old deprecated marquee tag, but it doesn't seem like either would work inside a table. I'm aware of the CSS solution to cell overflow that allows users to use a scroll bar to go through the text, I was wondering specifically if it's possible to automatically do this without any input from the user.


Solution

  • You can do it with @karthik's comment with a table, it is just easier with divs in my opinion.

    .tech-slideshow {
      height: 200px;
      max-width: 800px;
      margin: 0 auto;
      position: relative;
      overflow: hidden;
      transform: translate3d(0, 0, 0);
    }
    
    .tech-slideshow>td {
      height: 200px;
      width: 256px;
      position: absolute;
      top: 0;
      left: 0;
      height: 100%;
      transform: translate3d(0, 0, 0);
    }
    
    .tech-slideshow .mover-1 {
      animation: moveSlideshow 5s linear infinite;
    }
    
    @keyframes moveSlideshow {
      100% {
        transform: translateX(-66.6666%);
      }
    }
    <table>
      <tr class="tech-slideshow">
        <td class="mover-1">
          scrolling text scrolling text
        </td>
      </tr>
    </table>