有没有办法让html中的表单元格中的文本自动滚动,如股票或新闻自动收报机?我已经看到一些使用CSS来实现类似旧的不赞成选框标记的效果的例子,但它似乎不会在表格内部工作。我知道单元格溢出的CSS解决方案允许用户使用滚动条浏览文本,我特别想知道是否可以在没有用户输入的情况下自动执行此操作。< / p>
答案 0 :(得分:1)
你可以使用@ {kaceik&table
的评论来做到这一点,在我看来divs
会更容易。
.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%);
}
}
&#13;
<table>
<tr class="tech-slideshow">
<td class="mover-1">
scrolling text scrolling text
</td>
</tr>
</table>
&#13;
答案 1 :(得分:1)
这是一个小提琴,显示了在表格中使用div进行垂直滚动的示例。
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>