JSFiddle - React, Tailwind, and code Playground

by rami7250

HTML

<body>

<div class="ticker-container">
  <div class="ticker-caption">
    <p>Breaking News</p>
  </div>
  <ul>
    <div>
      <li><span>Great News Here 1 &ndash; <a href="#">Click Here</a></span></li>
    </div>
    <div>
      <li><span>Great News &ndash; <a href="#">Click Here</a></span></li>
    </div>
    <div>
      <li><span>Great  &ndash; <a href="#">Click Here</a></span></li>
    </div>
    <div>
      <li><span>Great News &ndash; <a href="#">Click Here</a></span></li>
    </div>
    <div>
      <li><span>Great News Here 5 &ndash; <a href="#">Click Here</a></span></li>
    </div>
  </ul>
</div>

</body>

CSS

* {
	margin: 0;
	padding: 0;
	font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}

.ticker-container {
	height: 60px;
	width: 500px;
	text-align: center;
	position: relative;
	overflow: hidden;
	background-color: rgba(0,0,0,1);
	color: white;
	/*background-color: white;
	color: black;*/
	font-size: 1.1em;
	margin-bottom: 15px;
}
.ticker-container .ticker-caption {
	height: 50%;
	width: 100%;
	background-color: #EC0B43;
	display: table;
	position: absolute;
	color: white;
	font-size: 0.8em;
	z-index: 1;
    direction: rtl;
}
.ticker-container .ticker-caption p {
	height: inherit;
	width: inherit;
	display: table-cell;
	vertical-align:middle;
	font-weight: bold;
}
.ticker-container ul {
	list-style: none;
	padding: 0;
	height: auto;  
}
.ticker-container ul div {
	overflow: hidden;
	position: absolute;
	z-index: 0;
	display: inline;
	min-width: 100%;
	left: 0;
	height: 50%;
	transition: 0.25s ease-in-out;
    
}
.ticker-container ul div.ticker-active {
	top: 30px;
}
.ticker-container ul div.not-active {
	top: 60px;
}
.ticker-container ul div.remove {
	top: 0;
}
.ticker-container ul div li {
	padding: 5px 0;
 
}
.ticker-container ul div li a {
	color: #EC0B43;
}

.ticker-container ul div li span {
	direction: rtl;
}

@media (min-width: 500px) {
	.ticker-container {
		height: 30px;
		text-align: left; 
        float: right;
	}
    
    .ticker-container .ticker-caption {right:0px;}
        
	.ticker-container .ticker-caption {
		height: 100%;
		width: 150px;
		background: url('http://www.jqueryscript.net/demo/Mobile-friendly-News-Ticker-with-jQuery-CSS3-Responsive-Ticker/ticker-caption-bg.png');
	}
	.ticker-container .ticker-caption p {
		text-align: right;
		padding-right: 9px;
        font-size: 17px;
	}
	.ticker-container ul {
		margin-left: 170px;
		height: 100%;
	}
	.ticker-container ul div {
		height: 100%;
		left: 8%;
	}
	.ticker-container ul div.ticker-active {
		top: 0;
	}
	.ticker-container ul div.not-active {
		top: 30px;
	}
	.ticker-container ul...

JavaScript

var speed = 5000;
canTick = true;

$(document).ready(function() {
	$('.ticker-container ul div').each(function(i) {
		if ($(window).width() >= 500) {
			$(this).find('li').width($(window).width() - parseInt($(this).css('left')));
		}
		if (i == 0) {
			$(this).addClass('ticker-active');
		} else {
			$(this).addClass('not-active');
		}
		if ($(this).find('li').height() > 30) {
			$(this).find('li').css({
				'height': '20px',
				'width': '200%',
				'text-align': 'left',
				'padding-left': '5px'
			});
			$(this).find('li').css('width', $(this).find('li span').width());
		}
	});
	startTicker();
	animateTickerElementHorz();
});

$(window).resize(function() {
	$('.ticker-container ul div').each(function(i) {
		if ($(this).find('li').height() > 30) {
			$(this).css({
				'height': '20px',
				'width': '200%',
				'text-align': 'left',
				'padding-left': '5px'
			});
			$(this).find('li').css('width', $(this).find('li span').width());
		}
	});
});

function startTicker() {
	setInterval(function() {
		if (canTick) {
			$('.ticker-container ul div.ticker-active')
				.removeClass('ticker-active')
				.addClass('remove');
			if ($('.ticker-container ul div.remove').next().length) {
				$('.ticker-container ul div.remove')
					.next()
					.addClass('next');
			} else {
				$('.ticker-container ul div')
					.first()
					.addClass('next');
			}
			$('.ticker-container ul div.next')
				.removeClass('not-active next')
				.addClass('ticker-active');
			setTimeout(function() {
				$('.ticker-container ul div.remove')
					.css('transition', '0s ease-in-out')
					.removeClass('remove')
					.addClass('not-active finished');
				if ($(window).width() < 500) {
					if ($('.ticker-container ul div.finished li').width() < $(window).width()) {
						$('.ticker-container ul div.finished').removeClass('finished');
					}
				} else {
					if ($('.ticker-container ul div.finished li').width() < ($(window).width() - (parseInt($('.ticker-container ul...