Friday, 17 May 2013
Simple News Ticker
This is how its started
Its a simple jquery news-ticker. Its very light weight and easy understandable
Script
/** news ticker* Rahmathullah*/var homeTicker = function (ticker) {var delay = 5000;var speed = 500;$(ticker+' li:first').fadeIn(speed);function tickOut(){$(ticker+' .ticker li:first').fadeOut(speed,function () {$(this).appendTo($(ticker+' .ticker'));$(ticker+' .ticker li:first').fadeIn(speed);});}var interval = setInterval(function(){ tickOut() }, delay);$(ticker+' #next').click(function() {clearInterval(interval);$(ticker+' .ticker li:first').fadeOut(speed,function () {$(this).appendTo($(ticker+' .ticker'));$(ticker+' .ticker li:first').fadeIn(speed);});interval = setInterval(function(){ tickOut() }, delay);});$(ticker+' #prev').click(function() {clearInterval(interval);$(ticker+' .ticker li:first').fadeOut(speed,function () {$(ticker+' .ticker li:last').prependTo($(ticker+' .ticker'));$(ticker+' .ticker li:first').fadeIn(speed);});interval = setInterval(function(){ tickOut() }, delay);});}
CSS
/* news */
.news-ticker {
width: 435px;
height: 200px;
background: #f4f4f4;
padding: 15px 18px;
float:left;
margin-left:15px;
}
.news-ticker .head {
float: left;
font-size: 22px;
font-family: 'myriad';
text-transform: uppercase;
color:#323232;
}
.news-ticker .navs {
float: right;
width: 64px;
}
.news-ticker h4 {
margin:10px 0;
color:#900;
font-size:18px;
font-weight:normal;
}
.news-ticker .navs .nav {
margin-left: 2px;
width: 30px;
height: 24px;
float: right;
cursor:pointer;
background-image: url(../images/arrows.png);
}
.news-ticker .navs #next {
background-position: 30px 0px;
}
.news-ticker .navs #prev {
background-position: 0px 0px;
}
.news-ticker .navs #next:hover {
background-position: 30px 24px;
}
.news-ticker .navs #prev:hover {
background-position: 0px 24px;
}
.news-ticker .head .red {
color: #c51500;
}
.news-ticker ul {
height: 170px;
overflow: hidden;
list-style: none;
padding: 0;
font-family:Verdana, Geneva, sans-serif;
font-size:11px;
}
.news-ticker ul .news-head{
font-weight:bold;
margin-top:15px;
}
.news-ticker li {
height: 175px;
display:none;
}
.clear {
clear: both;
}
HTML
<div class="news-ticker">
<div class="head">
News Updates
</div>
<div class="navs">
<a class="nav" id="next" ></a>
<a class="nav" id="prev" ></a>
</div>
<div class="clear"></div>
<ul class="ticker">
<li>
<h4>News title 1</h4>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</li>
<li>
<h4>News title 1</h4>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</li>
</ul>
</div>
This is how its started
<script type="text/javascript">
$(document).ready(function() {
homeTicker('.news-ticker');
});
</script>
Subscribe to:
Posts (Atom)