Breaking news ticker html code
Here is an example of HTML code for a breaking news ticker:
<!-- Breaking News Ticker -->
<div class="breaking-news-ticker">
<ul>
<li><span class="ticker-text">Breaking News: <a rel="nofollow" target="_blank" href="#">Headline 1</a></span></li>
<li><span class="ticker-text">Breaking News: <a rel="nofollow" target="_blank" href="#">Headline 2</a></span></li>
<li><span class="ticker-text">Breaking News: <a rel="nofollow" target="_blank" href="#">Headline 3</a></span></li>
<!-- Add more headlines here -->
</ul>
</div>
And here is some CSS code to style the breaking news ticker:
.breaking-news-ticker {
position: relative;
width: 100%;
height: 30px;
background-color: #333;
color: #fff;
padding: 10px;
font-size: 16px;
font-weight: bold;
text-align: center;
overflow: hidden;
}
.breaking-news-ticker ul {
list-style: none;
margin: 0;
padding: 0;
}
.breaking-news-ticker li {
display: inline-block;
margin-right: 10px;
}
.breaking-news-ticker.ticker-text {
font-size: 16px;
font-weight: bold;
text-decoration: none;
color: #fff;
}
.breaking-news-ticker.ticker-text:hover {
text-decoration: underline;
}
And here is some JavaScript code to animate the breaking news ticker:
// Get the breaking news ticker element
var ticker = document.querySelector('.breaking-news-ticker');
// Set the animation interval
var interval = setInterval(function() {
// Get the current list item
var currentItem = ticker.querySelector('li');
// Move the current item to the end of the list
ticker.appendChild(currentItem);
// Remove the first item from the list
ticker.removeChild(ticker.querySelector('li:first-child'));
// Update the animation
ticker.style.transform = 'translateX(-100%)';
ticker.style.transition = 'transform 0.5s ease-in-out';
}, 5000); // Update every 5 seconds
This code creates a breaking news ticker that displays a list of headlines. The headlines are animated to move from right to left, with the oldest headline disappearing from view and the newest headline appearing at the end of the list. You can customize the appearance and behavior of the ticker by modifying the HTML, CSS, and JavaScript code.
Note: This is just an example code, you can adjust it according to your needs and also you can use libraries like jQuery to make it more easy to implement.