Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 283
Courtland Crouchet Avatar asked May 15 '18 15:05

Courtland Crouchet


People also ask

How do you put a scroll on a table in HTML?

Suppose we want to add a scroll bar option in HTML, use an “overflow” option and set it as auto-enabled for adding both horizontal and vertical scroll bars. If we want to add a vertical bar option in Html, add the line “overflow-y” in the files.

How do I scroll text without marquee in HTML?

You can use the :hover selector with the animation-play-state property to stop the scrolling of the text when hovered. Set the "paused" value for the animation-play-state .

How do you use overflow in a table?

The overflowing content can be clipped, display an ellipsis ('…'), or display a custom string. Syntax: text-overflow: clip|string|ellipsis|initial|inherit; Example: In the following example,we will consider ellipsis to use the test-overflow property in a table cell.


2 Answers

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>
like image 84
Scath Avatar answered Oct 13 '22 17:10

Scath


Here is a fiddle showing example of using a div inside a table for vertical scrolling.

table.scrollable-content tbody tr{
  overflow:auto;
  display:block;
  height:30px;
}
table.scrollable-content tbody tr div{
    animation-name: example;
    animation-duration: 5s;
}
table.scrollable-content tbody tr:hover div{
    animation-name: example2;
    animation-duration: 5s;
}

@keyframes example {
    from {background-color: rgba(250,0,0,0.5);}
    to {
      background-color: rgba(250,250,0,0.5);
       transform:translateY(-30px)
    }
}
@keyframes hovered {
    from {background-color: rgba(250,0,0,0.5);}
    to {
      background-color: rgba(250,250,0,0.5);
       transform:translateY(-30px)
    }
}
<table class="scrollable-content">
<thead><tr><th>header</th></tr></thead>
<tbody>
<tr>
<td>
<div>
Body with very long text,Body with very long text,<br/>Body with very long text,Body with very long text,Body with very long text,Body with very long text,Body with very long text,Body with very long text,Body with very long text
</div>
</td>
</tr>
</tbody>
</table>
See code in fiddle https://jsfiddle.net/2vkp1g7a/
like image 28
jidexl21 Avatar answered Oct 13 '22 15:10

jidexl21