Two jquery news headlines fade effect

Source: Internet
Author: User

Cases

Code

The code is as follows Copy Code

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">


<html xmlns= "http://www.w3.org/1999/xhtml" >


<head>


<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>


<title> Untitled Document </title>


<script type= ' text/javascript ' src= ' jquery-1.2.6.min.js ' ></script>


<style type= "Text/css" >


#gallery1 {width:100%; overflow:hidden;}


#gallery1 a {position:relative; float:left; margin:5px;}


#gallery1 a span {display:none background-image:url (zoom.png); background-repeat:no-repeat; width:48px; height:48px; Position:absolute; left:15px; top:15px;}


#gallery1 img {border:solid 1px #999; padding:5px;}


#gallery1 a:hover span {Display:block}





#gallery2 {width:100%; overflow:hidden;}


#gallery2 a {position:relative; float:left; margin:5px;}


#gallery2 a span {display:none background-image:url (zoom.png); background-repeat:no-repeat; width:48px; height:48px; Position:absolute; left:15px; top:15px;}


#gallery2 img {border:solid 1px #999; padding:5px;}





</style>


<script>


$ (document). Ready (function () {


$ ("#gallery2 a"). Append ("<span></span>");


$ ("#gallery2 a"). Hover (function () {


$ (this). Children ("span"). FadeIn (600);


},function () {


$ (this). Children ("span"). fadeout (200);


});


});


</script>


</head>


<body>


<div id= "Gallery1" >


<h2>css solution</h2>


<a href= "1.jpg" >


<span></span>


<img src= "1.jpg" alt= ""/>


</a>


<a href= "2.jpg" >


<span></span>


<img src= "2.jpg" alt= ""/>


</a>


</div>





<div id= "Gallery2" >


<h2>jquery solution</h2>


<a href= "1.jpg" >


<img src= "1.jpg" alt= ""/>


</a>


<a href= "2.jpg" >


<img src= "2.jpg" alt= ""/>


</a>


</div>


</body>


</html>

Example 2

The code is as follows Copy Code

<! DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">


<html xmlns= "http://www.w3.org/1999/xhtml" >


<head>


<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">


<title></title>


<style>


A {color: #CCCCCC}


Li {list-style:none;}


span {padding-right:20px; color: #FFFFFF; font-weight:bold;}


</style>


</head>


<body>


<div id= "Ticker" style= "padding:10px; Background: #333333 ">


<!--START Ticker VER 1.0.1-->


<script src= "Http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js" type= "Text/javascript" ></script >


<script type= "Text/javascript" >


/* =========================================================


Jquery.innerfade.js


Datum:2008-02-14


Firma:medienfreunde Hofmann & Baldes GbR


Author:torsten Baldes


Mail:t.baldes@medienfreunde.com


Web:http://medienfreunde.com


Based on the work of Matt Oakes http://portfolio.gizone.co.uk/applications/slideshow/


and Ralf S. Engelschall http://trainofthoughts.org/


*


* <ul id= "News" >


* <li>content 1</li>


* <li>content 2</li>


* <li>content 3</li>


* </ul>


*


* $ (' #news '). Innerfade ({


* Animationtype:type of animation ' fade ' or ' Slide ' (Default: ' fade '),


* Speed:fading-/sliding-speed in milliseconds or keywords (slow, normal or fast) (Default: ' normal '),


* Timeout:time between the fades in milliseconds (Default: ' 2000 '),


* Type:type of slideshow: ' Sequence ', ' random ' or ' Random_start ' (Default: ' Sequence '),


* Containerheight:height of the containing element in any Css-height-value (Default: ' Auto '),


* Runningclass:css-class which the container get ' s applied (Default: ' Innerfade '),


* Children:optional Children selector (default:null)


*  });


*


// ========================================================= */


(function ($) {


$.fn.innerfade = function (options) {


Return This.each (function () {


$.innerfade (this, options);


});


};


$.innerfade = function (container, options) {


var settings = {


' Animationtype ': ' fade ',


' Speed ': ' normal ',


' type ': ' Sequence ',


' Timeout ': 2000,


' Containerheight ': ' Auto ',


' Runningclass ': ' Innerfade ',


' Children ': null


};


if (options)


$.extend (settings, options);


if (Settings.children = = null)


var elements = $ (container). Children ();


Else


var elements = $ (container). Children (Settings.children);


if (Elements.length > 1) {


$ (container). css (' position ', ' relative '). css (' height ', settings.containerheight). addclass (Settings.runningclass) ;


for (var i = 0; i < elements.length; i++) {


$ (elements[i]). CSS (' Z-index ', String (elements.length-i)). css (' position ', ' absolute '). Hide ();


};


if (Settings.type = = "sequence") {


settimeout (function () {


$.innerfade.next (elements, settings, 1, 0);


}, Settings.timeout);


$ (elements[0]). Show ();


else if (Settings.type = = "Random") {


var last = Math.floor (Math.random () * (elements.length));


settimeout (function () {


do {


Current = Math.floor (Math.random () * (elements.length));


while (last = = current);


$.innerfade.next (elements, settings, current, last);


}, Settings.timeout);


$ (Elements[last]). Show ();


else if (Settings.type = = ' Random_start ') {


Settings.type = ' sequence ';


var current = Math.floor (Math.random () * (elements.length));


settimeout (function () {


$.innerfade.next (Elements, settings, (current + 1)% elements.length, current);


}, Settings.timeout);


$ (elements[current]). Show ();


} else {


Alert (' Innerfade-type must either be ' sequence ', ' random ' or ' random_start ');


}


}


};


$.innerfade.next = function (elements, settings, current, last) {


if (Settings.animationtype = = ' Slide ') {


$ (Elements[last]). Slideup (Settings.speed);


$ (elements[current]). Slidedown (Settings.speed);


else if (Settings.animationtype = = ' fade ') {


$ (Elements[last]). fadeout (Settings.speed);


$ (elements[current]). FadeIn (Settings.speed, function () {


Removefilter ($ (this) [0]);


});


} else


Alert (' Innerfade-animationtype must either be ' slide ' or ' fade ');


if (Settings.type = = "sequence") {


if ((current + 1) < Elements.length) {


Current = current + 1;


last = current-1;


} else {


current = 0;


last = elements.length-1;


}


else if (Settings.type = = "Random") {


last = current;


while (current = = last)


Current = Math.floor (Math.random () * elements.length);


} else


Alert (' Innerfade-type must either be ' sequence ', ' random ' or ' random_start ');


settimeout (function () {


$.innerfade.next (elements, settings, current, last);


}), settings.timeout);


};


}) (JQuery);


Remove Opacity-filter in IE * * * *


function removefilter (Element) {


if (Element.style.removeAttribute) {


Element.style.removeAttribute (' filter ');


}


}


</script>


<script type= "Text/javascript" >


Jquery.noconflict ();


Use jquery via jquery (...)


JQuery (document). Ready (function () {


JQuery (' #news '). Innerfade ({


Speed: ' 1 ',


timeout:2000,


CONTAINERHEIGHT:20,


Animationtype: ' fade '


});


});


</script>


<ul id= "News" style= "Overflow:hidden; Display:block; margin:0; Clear:both ">


<li style= "Z-INDEX:5; Position:absolute; Display:none; " ><span>hot news</span><a href= "#" >racing has begun at the 2009 Allegrocup Windsurfing Championship I N. EBA, Poland. This event, organised by ... </a></li>


<li style= "Z-INDEX:4; Position:absolute; Display:none; " ><span>hot news</span><a href= "#" >sean is currently racing on the Euro-challenger FW Event in Pobiero WO, Poland. A small seaside town on the ... </a></li>


<li style= "Z-INDEX:3; Position:absolute; Display:list-item; " ><span>hot news</span><a href= "#" >sean'll be joining the dark side of windsurfing this season, on T He International Point-7 sails .... </a></li>


<li style= "Z-INDEX:2; Position:absolute; Display:none; " ><span>hot news</span><a href= "#" >sean ' all new website for 2009 launched Stay tuned for features on many CSS galleries once. The ... </a></li>


<li style= "Z-INDEX:1; Position:absolute; Display:none; " ><span>hot news</span><a href= "#" >sean has just arrived in Europe and settled into his training-base In the Netherlands, preparing for this ... </a></li>


</ul>


<!--end Ticker-->


</div>


</body>


</html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.