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.
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.
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 .
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.
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>
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With