<div class="news-ticker" data-speed="5000">
<ul>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. 1</li>
<li>Sed eget diam sit amet dolor lacinia maximus eget quis quam. 2</li>
<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. 3</li>
<li>Sed eget diam sit amet dolor lacinia maximus eget quis quam. 4</li>
</ul>
<span class="close-ticker"><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="50" height="50" id="svg2"> <defs id="defs4"/> <metadata id="metadata7"> <rdf:RDF> <cc:Work rdf:about=""> <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/> <dc:title></dc:title> </cc:Work> </rdf:RDF> </metadata> <g transform="translate(0,-1002.3622)" id="layer1"> <rect width="5" height="35" ry="0.025385702" x="741.69556" y="691.34021" transform="matrix(0.70710678,0.70710678,-0.70710678,0.70710678,0,0)" id="rect2987" style="fill:#ffffff;fill-opacity:1;stroke:none"/> <rect width="5" height="35" ry="0.025385702" x="706.34021" y="726.69556" transform="matrix(-0.70710678,0.70710678,0.70710678,0.70710678,0,0)" id="rect2987-1" style="fill:#ffffff;fill-opacity:1;stroke:none"/> </g></svg></span>
</div>
body {
margin: 0;
}
.news-ticker,
.news-ticker li {
width: 100%;
position: absolute;
padding: 0;
margin: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.news-ticker ul {
list-style: none;
padding: 0;
margin: 0;
}
.news-ticker {
height: 50px;
top: 0;
left: 0;
background-color: #212121;
color: #fff;
font-family: 'Open Sans', sans-serif;
}
.news-ticker li {
text-align: center;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
}
.close-ticker {
width: 50px;
height: 50px;
position: absolute;
right: 0;
top: 0;
cursor: pointer;
}
jQuery(document).ready(function($){
var tickerSpeed = $('.news-ticker').attr('data-speed');
$('.news-ticker ul li').hide();
$('.news-ticker ul li:first').show();
var currentSlide = 0;
var slideCount = ($('.news-ticker li').length) - 1;
var startTicker = setInterval(function(){
$('.news-ticker ul li').eq(currentSlide).fadeOut(500)
if (currentSlide < slideCount) {
currentSlide += 1;
} else {
currentSlide = 0;
}
$('.news-ticker ul li').eq(currentSlide).fadeIn(500)
}, tickerSpeed);
$('.close-ticker').on('click', function(){
clearInterval(startTicker);
$('.news-ticker').fadeOut(500, function(){
$(this).remove();
});
});
});