JSFiddle - React, Tailwind, and code Playground
by hohoya33
HTML
<div class="beerlist">
<div class="bl-wrapper">
<div class="beer-number">#</div>
<div class="beer-logo">img</div>
<div class="dp-slide">
<span class="beer-info">
<span class="brewery-name">brewery</span>
<span class="beverage-name">beverage name beverage name</span>
</span>
<br>
<span class="beer-info">
<span class="beverage-style">beverage style</span>
</span>
<br>
<span class="beer-info">
<span class="brewery-location">location</span>
</span>
</div>
<div class="glass-1">snifter</div>
<div class="glass-1">pint</div>
<div class="glass-1">can</div>
</div>
</div>
CSS
.bl-wrapper > div {
display: inline-block;
}
.dp-slide {
max-height: 80px;
max-width: 200px;
overflow: hidden;
vertical-align: middle;
transform: translate3d(0, 0, 0);
}
.beer-info {
white-space: nowrap;
display: inline-block;
width: 250px;
}
@keyframes moveSlideshow {
100% {
transform: translateX(-66.6666%);
}
}
.mover-1 {
animation: moveSlideshow 6s linear infinite;
-moz-animation: moveSlideshow 6s linear infinite;
-webkit-animation: moveSlideshow 6s linear infinite;
-o-animation: moveSlideshow 6s linear infinite;
animation-delay: 2s;
-moz-animation-delay: 2s;
-webkit-animation-delay: 2s;
-o-animation-delay: 2s;
}
JavaScript
$(function() {
$('span.beer-info').each(function(i) {
var element = $(this)
.clone()
.css({display: 'inline', width: 'auto', visibility: 'hidden'})
.appendTo('body');
if( element.width() > $(this).width() ) {
$(this).addClass( "mover-1" );
// This is an example calculation, you can find a formula that works for you
$(this).css('animation-duration', ($(this).width() / element.width() * 4) + 's')
}
element.remove();
});
});