Here's a pure CSS solution. The CSS property transform: translateX()
, @keyframes
, and CSS animation is used in the demo. If for some inconceivable reason your browser is pre-2017, a JavaScript prefix function is provided.
var animation = false,
animationstring = 'animation',
keyframeprefix = '',
domPrefixes = 'Webkit Moz O ms Khtml'.split(' '),
pfx = '',
elem = document.createElement('div');
if( elem.style.animationName !== undefined ) { animation = true; }
if( animation === false ) {
for( var i = 0; i < domPrefixes.length; i++ ) {
if( elem.style[ domPrefixes[i] + 'AnimationName' ] !== undefined ) {
pfx = domPrefixes[ i ];
animationstring = pfx + 'Animation';
keyframeprefix = '-' + pfx.toLowerCase() + '-';
animation = true;
break;
}
}
}
:root {
font: 400 16px/1.5 Verdana;
}
html,
body {
width: 100%;
height: 100%;
}
body {
overflow: hidden;
}
.table {
table-layout: fixed;
border-collapse: collapse;
width: 90%;
margin: 5px auto;
}
td {
width: 15%;
text-align: center;
border: 3px solid rgba(233, 233, 233, 0.3);
}
td:last-of-type {
width: 70%;
}
td>b {
display: block;
margin: -15px auto 0;
font-size: 1.5rem;
color: tomato;
}
.marquee {
width: 90%;
/* Required on Parent */
overflow: hidden;
background: rgba(0, 0, 0, 0.7);
padding-left: 15px;
margin: 20px auto;
font-size: 2rem;
}
.scroll {
/* Required on Child*/
white-space: nowrap;
display: table-cell;
color: cyan;
vertical-align: baseline;
/* Infinite Loops */
animation: rightToLeft 12s linear infinite;
/* Right to left direction */
animation-fill-mode: backwards;
/* Set to 0s in order to have a point of reference */
animation-delay: 0s;
}
.scroll::before {
content: ' ';
}
.scroll::after {
content: ' ';
}
.scroll a {
color: gold
}
/* Required for complex CSS animation */
@keyframes rightToLeft {
0% {
transform: translateX(20%);
}
100% {
transform: translateX(-100%);
}
}
<table class='table'>
<tbody>
<tr>
<td>15%<b>⟺</b></td>
<td>15%<b>⟺</b></td>
<td>
<figure class='marquee'>
<figcaption class='scroll'>You should read <i>“how to ask”</i>: <a href="https://stackoverflow.com/help/how-to-ask">https://stackoverflow.com/help/how-to-ask</a></figcaption>
</figure>
</td>
</tr>
<tr>
<td>15%<b>⟺</b></td>
<td>15%<b>⟺</b></td>
<td>
<figure class='marquee'>
<figcaption class='scroll'></figcaption>
</figure>
</td>
</tr>
</tbody>
</table>