jQuery手风琴动画特效插件特效代码

版权:原创 更新时间:1年以上
[该文章底部包含文件资源,可根据自己情况,决定是否下载资源使用,时间>金钱,如有需要,立即查看资源]

以下是 jQuery手风琴动画特效插件特效代码 的示例演示效果:

当前平台(PC电脑)
  • 平台:

部分效果截图:

jQuery手风琴动画特效插件特效代码

HTML代码(index.html):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
	  <title>jQuery Easy Accordion Plugin</title>
	  
      <!-- Meta -->
      <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
	  <meta name="author" content="Andrea Cima Serniotti - Madeincima.eu" />
	  <meta name="description" content="jQuery Easy Accordion Plugin - A highly flexible timed horizontal slider able to show any kind of content" />
	  <meta name="keywords" content="jQuery, plugin, accordion, slider, slideshow, horizontal, timed, interval" />	  
      
      <!-- Scripts -->
      <script type="text/javascript" src="scripts/jquery.min.js"></script>
	  <script type="text/javascript" src="scripts/jquery.easyAccordion.js"></script>
      <script type="text/javascript" src="scripts/utility.js"></script>
      
      <style type="text/css">
		  html{font-size:62.5%}
		  body{font-size:1.2em;color:#294f88}
		  .sample{margin:30px;border:1px solid #92cdec;background:#d7e7ff;padding:30px}
		  h1{margin:0 0 20px 0;padding:0;font-size:2em;}
		  h2{margin:40px 0 20px 0;padding:0;font-size:1.6em;}
		  .easy-accordion h2{margin:0px 0 20px 0;padding:0;font-size:1.6em;}
		  p{font-size:1.2em;line-height:170%;margin-bottom:20px}
		  		  
		 
		/* UNLESS YOU KNOW WHAT YOU'RE DOING, DO NOT CHANGE THE FOLLOWING RULES */
		
		.easy-accordion{display:block;position:relative;overflow:hidden;padding:0;margin:0}
		.easy-accordion dt,.easy-accordion dd{margin:0;padding:0}
		.easy-accordion dt,.easy-accordion dd{position:absolute}
		.easy-accordion dt{margin-bottom:0;margin-left:0;z-index:5;/* Safari */ -webkit-transform: rotate(-90deg); /* Firefox */ -moz-transform: rotate(-90deg);-moz-transform-origin: 20px 0px;  /* Internet Explorer */ filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);cursor:pointer;}
		.easy-accordion dd{z-index:1;opacity:0;overflow:hidden}
		.easy-accordion dd.active{opacity:1;}
		.easy-accordion dd.no-more-active{z-index:2;opacity:1}
		.easy-accordion dd.active{z-index:3}
		.easy-accordion dd.plus{z-index:4}
		.easy-accordion .slide-number{position:absolute;bottom:0;left:10px;font-weight:normal;font-size:1.1em;/* Safari */ -webkit-transform: rotate(90deg); /* Firefox */ -moz-transform: rotate(90deg);  /* Internet Explorer */ filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);}
		 
		 
		/* FEEL FREE TO CUSTOMIZE THE FOLLOWING RULES */
		
		dd p{line-height:120%}
		
		#accordion-1{width:800px;height:245px;padding:30px;background:#fff;border:1px solid #b5c9e8}
		#accordion-1 dl{width:800px;height:245px}	
		#accordion-1 dt{height:46px;line-height:44px;text-align:right;padding:0 15px 0 0;font-size:1.1em;font-weight:bold;font-family: Tahoma, Geneva, sans-serif;text-transform:uppercase;letter-spacing:1px;background:#fff url(images/slide-title-inactive-1.jpg) 0 0 no-repeat;color:#26526c}
		#accordion-1 dt.active{cursor:pointer;color:#fff;background:#fff url(images/slide-title-active-1.jpg) 0 0 no-repeat}
		#accordion-1 dt.hover{color:#68889b;}
		#accordion-1 dt.active.hover{color:#fff}
		#accordion-1 dd{padding:25px;background:url(images/slide.jpg) bottom left repeat-x;border:1px solid #dbe9ea;border-left:0;margin-right:3px}
		#accordion-1 .slide-number{color:#68889b;left:10px;font-weight:bold}
		#accordion-1 .active .slide-number{color:#fff;}
		#accordion-1 a{color:#68889b}
		#accordion-1 dd img{float:right;margin:0 0 0 30px;}
		#accordion-1 h2{font-size:2.5em;margin-top:10px}
		#accordion-1 .more{padding-top:10px;display:block}
			
		#accordion-2{width:700px;height:195px;padding:30px;background:#fff;border:1px solid #b5c9e8}
		#accordion-2 h2{font-size:2.5em;margin-top:10px}
		#accordion-2 dl{width:700px;height:195px}	
		#accordion-2 dt{height:56px;line-height:44px;text-align:right;padding:10px 15px 0 0;font-size:1.1em;font-weight:bold;font-family: Tahoma, Geneva, sans-serif;text-transform:uppercase;letter-spacing:1px;background:#fff url(images/slide-title-inactive-2.jpg) 0 0 no-repeat;color:#26526c}
		#accordion-2 dt.active{cursor:pointer;color:#fff;background:#fff url(images/slide-title-active-2.jpg) 0 0 no-repeat}
		#accordion-2 dt.hover{color:#68889b;}
		#accordion-2 dt.active.hover{color:#fff}
		#accordion-2 dd{padding:25px;background:url(images/slide.jpg) bottom left repeat-x;border:1px solid #dbe9ea;border-left:0;margin-right:3px}
		#accordion-2 .slide-number{color:#68889b;left:10px;font-weight:bold}
		#accordion-2 .active .slide-number{color:#fff}
		#accordion-2 a{color:#68889b}
		#accordion-2 dd img{float:right;margin:0 0 0 30px;position:relative;top:-20px}

		#accordion-3{width:700px;height:195px;padding:30px;background:#fff;border:1px solid #b5c9e8}
		#accordion-3 h2{font-size:2.5em;margin-top:10px}
		#accordion-3 dl{width:700px;height:195px}	
		#accordion-3 dt{height:56px;line-height:44px;text-align:right;padding:10px 15px 0 0;font-size:1.1em;font-weight:bold;font-family: Tahoma, Geneva, sans-serif;text-transform:uppercase;letter-spacing:1px;background:#fff url(images/slide-title-inactive-2.jpg) 0 0 no-repeat;color:#26526c}
		#accordion-3 dt.active{cursor:pointer;color:#fff;background:#fff url(images/slide-title-active-2.jpg) 0 0 no-repeat}
		#accordion-3 dt.hover{color:#68889b;}
		#accordion-3 dt.active.hover{color:#fff}
		#accordion-3 dd{padding:25px;background:url(images/slide.jpg) bottom left repeat-x;border:1px solid #dbe9ea;border-left:0;margin-right:3px}
		#accordion-3 .slide-number{color:#68889b;left:13px;font-weight:bold}
		#accordion-3 .active .slide-number{color:#fff}
		#accordion-3 a{color:#68889b}
		#accordion-3 dd img{float:right;margin:0 0 0 30px;position:relative;top:-20px}

      </style>
      
</head>
<body>

    <div class="sample">
        <h1>jQuery Easy Accordion Plugin</h1>
        
        <h2>Horizontal Accordion with Autoplay</h2>
        <p>Set the '<strong>autoStart</strong>' parameter to '<strong>true</strong>' to get a timed slideshow. You can also define the interval between each slide in milliseconds using the '<strong>slideInterval</strong>' parameter.</p>
        <div id="accordion-1">
            <dl>
                <dt>First slide</dt>
                <dd><h2>This is the first slide</h2><p><img src="images/monsters/img1.png" alt="Alt text to go here" />Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, enim.<br /><a href="#" class="more">Read more</a></p></dd>
                <dt>Second slide</dt>
                <dd><h2>Here is the second slide</h2><p><img src="images/monsters/img2.png" alt="Alt text to go here" />Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, enim.<br /><a href="#" class="more">Read more</a></p></dd>
                <dt>One more slide</dt>
                <dd><h2>One more slide to go here</h2><p><img src="images/monsters/img3.png" alt="Alt text to go here" />Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, enim.<br /><a href="#" class="more">Read more</a></p></dd>
                <dt>Another slide</dt>
                <dd><h2>Another slide to go here</h2><p><img src="images/monsters/img4.png" alt="Alt text to go here" />Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, enim.<br /><a href="#" class="more">Read more</a></p></dd>
                <dt>Wow one more</dt>
                <dd><h2>Unbilievable one more slide here</h2><p><img src="images/monsters/img5.png" alt="Alt text to go here" />Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, enim.<br /><a href="#" class="more">Read more</a></p></dd>
                <dt>Last one</dt>
                <dd><h2>This is definitely the last one</h2><p><img src="images/monsters/img6.png" alt="Alt text to go here" />Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, enim.<br /><a href="#" class="more">Read more</a></p></dd>
            </dl>
        </div>
 		
        <h2>Simple Horizontal Accordion</h2>
        <p>If you don't specify the '<strong>autoStart</strong>' parameter or if you set it to '<strong>false</strong>' you get a simple slideshow.</p>

        <div id="accordion-2">
            <dl>
                <dt>Slide title</dt>
                <dd><h2>First mammoth here</h2><p><img src="images/mammoths/img1.png" alt="Alt text to go here" />Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean commodo ligula eget dolor.</p></dd>
                <dt>Another slide</dt>
                <dd><h2>Over the moon!</h2><p><img src="images/mammoths/img2.png" alt="Alt text to go here" />Aenean commodo ligula eget dolor. Aenean massa. Nascetur aenean commodo ligula eget dolor. Aenean massa eget. </p></dd>
                <dt>Third slide</dt>
                <dd><h2>Another mammoth</h2><p><img src="images/mammoths/img3.png" alt="Alt text to go here" />Ipsum dolor sit amet.Aenean ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur.</p></dd>
                <dt>Last slide</dt>
                <dd><h2>This is my favourite</h2><p><img src="images/mammoths/img4.png" alt="Alt text to go here" />Cum sociis natoque penatibus et donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.</p></dd>
           </dl>
        </div>
        
        <h2>Set the initial Active Slide</h2>
        <p>You can easily set the <strong>initial active slide</strong> by adding the '<strong>active</strong>' class to the respective DT element.
        <br />Notice that you could also remove the slide number by setting the '<strong>slideNum</strong>' parameter to '<strong>false</strong>'.</p>
        <div id="accordion-3">
            <dl>
                <dt>Slide title</dt>
                <dd><h2>First slide here</h2><p><img src="images/bugs/img2.png" alt="Alt text to go here" />Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean commodo ligula eget dolor.</p></dd>
                <dt>Another slide</dt>
                <dd><h2>Title to go here</h2><p><img src="images/bugs/img4.png" alt="Alt text to go here" />Aenean commodo ligula eget dolor. Aenean massa. Nascetur aenean commodo ligula eget dolor. Aenean massa eget. </p></dd>
                <dt class="active">Third slide</dt>
                <dd><h2>Here is the title</h2><p><img src="images/bugs/img1.png" alt="Alt text to go here" />Ipsum dolor sit amet.Aenean ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur.</p></dd>
                <dt>Last slide</dt>
                <dd><h2>Last slide title</h2><p><img src="images/bugs/img3.png" alt="Alt text to go here" />Cum sociis natoque penatibus et donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim.</p></dd>
           </dl>
        </div>

    </div>
    
</body>
</html>






JS代码(jquery.easyAccordion.js):

/* *easyAccordion 0.1 - jQuery plugin *written by Andrea Cima Serniotti *http://www.madeincima.eu * *Copyright (c) 2010 Andrea Cima Serniotti (http://www.madeincima.eu) *Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. *Built for jQuery library http://jquery.com */
(function(jQuery){
	jQuery.fn.easyAccordion = function(options){
	var defaults ={
	slideNum:true,autoStart:false,slideInterval:3000}
;
	this.each(function(){
	var settings = jQuery.extend(defaults,options);
	jQuery(this).find('dl').addClass('easy-accordion');
	// -------- Set the variables ------------------------------------------------------------------------------jQuery.fn.setVariables = function(){
	dlWidth = jQuery(this).width();
	dlHeight = jQuery(this).height();
	dtWidth = jQuery(this).find('dt').outerHeight();
	if (jQuery.browser.msie){
	dtWidth = $(this).find('dt').outerWidth();
}
dtHeight = dlHeight - (jQuery(this).find('dt').outerWidth()-jQuery(this).find('dt').width());
	slideTotal = jQuery(this).find('dt').size();
	ddWidth = dlWidth - (dtWidth*slideTotal) - (jQuery(this).find('dd').outerWidth(true)-jQuery(this).find('dd').width());
	ddHeight = dlHeight - (jQuery(this).find('dd').outerHeight(true)-jQuery(this).find('dd').height());
}
;
	jQuery(this).setVariables();
	// -------- Fix some weird cross-browser issues due to the CSS rotation -------------------------------------if (jQuery.browser.safari){
	var dtTop = (dlHeight-dtWidth)/2;
	var dtOffset = -dtTop;
	/* Safari and Chrome */
}
if (jQuery.browser.mozilla){
	var dtTop = dlHeight - 20;
	var dtOffset = - 20;
	/* FF */
}
if (jQuery.browser.msie){
	var dtTop = 0;
	var dtOffset = 0;
	/* IE */
}
// -------- Getting things ready ------------------------------------------------------------------------------var f = 1;
	jQuery(this).find('dt').each(function(){
	jQuery(this).css({
	'width':dtHeight,'top':dtTop,'margin-left':dtOffset}
);
	if(settings.slideNum == true){
	jQuery('<span class="slide-number">'+0+f+'</span>').appendTo(this);
	if(jQuery.browser.msie){
	var slideNumLeft = parseInt(jQuery(this).find('.slide-number').css('left')) - 14;
	jQuery(this).find('.slide-number').css({
	'left':slideNumLeft}
)if(jQuery.browser.version == 6.0 || jQuery.browser.version == 7.0){
	jQuery(this).find('.slide-number').css({
	'bottom':'auto'}
);
}
if(jQuery.browser.version == 8.0){
	var slideNumTop = jQuery(this).find('.slide-number').css('bottom');
	var slideNumTopVal = parseInt(slideNumTop) + parseInt(jQuery(this).css('padding-top')) - 12;
	jQuery(this).find('.slide-number').css({
	'bottom':slideNumTopVal}
);
}
}
else{
	var slideNumTop = jQuery(this).find('.slide-number').css('bottom');
	var slideNumTopVal = parseInt(slideNumTop) + parseInt(jQuery(this).css('padding-top'));
	jQuery(this).find('.slide-number').css({
	'bottom':slideNumTopVal}
);
}
}
f = f + 1;
}
);
	if(jQuery(this).find('.active').size()){
	jQuery(this).find('.active').next('dd').addClass('active');
}
else{
	jQuery(this).find('dt:first').addClass('active').next('dd').addClass('active');
}
jQuery(this).find('dt:first').css({
	'left':'0'}
).next().css({
	'left':dtWidth}
);
	jQuery(this).find('dd').css({
	'width':ddWidth,'height':ddHeight}
);
	// -------- Functions ------------------------------------------------------------------------------jQuery.fn.findActiveSlide = function(){
	var i = 1;
	this.find('dt').each(function(){
	if(jQuery(this).hasClass('active')){
	activeID = i;
	// Active slide}
else if (jQuery(this).hasClass('no-more-active')){
	noMoreActiveID = i;
	// No more active slide}
i = i + 1;
}
);
}
;
	jQuery.fn.calculateSlidePos = function(){
	var u = 2;
	jQuery(this).find('dt').not(':first').each(function(){
	var activeDtPos = dtWidth*activeID;
	if(u <= activeID){
	var leftDtPos = dtWidth*(u-1);
	jQuery(this).animate({
	'left':leftDtPos}
);
	if(u < activeID){
	// If the item sits to the left of the active elementjQuery(this).next().css({
	'left':leftDtPos+dtWidth}
);
}
else{
	// If the item is the active onejQuery(this).next().animate({
	'left':activeDtPos}
);
}
}
else{
	var rightDtPos = dlWidth-(dtWidth*(slideTotal-u+1));
	jQuery(this).animate({
	'left':rightDtPos}
);
	var rightDdPos = rightDtPos+dtWidth;
	jQuery(this).next().animate({
	'left':rightDdPos}
);
}
u = u+ 1;
}
);
	setTimeout( function(){
	jQuery('.easy-accordion').find('dd').not('.active').each(function(){
	jQuery(this).css({
	'display':'none'}
);
}
);
}
,400);
}
;
	jQuery.fn.activateSlide = function(){
	this.parent('dl').setVariables();
	this.parent('dl').find('dd').css({
	'display':'block'}
);
	this.parent('dl').find('dd.plus').removeClass('plus');
	this.parent('dl').find('.no-more-active').removeClass('no-more-active');
	this.parent('dl').find('.active').removeClass('active').addClass('no-more-active');
	this.addClass('active').next().addClass('active');
	this.parent('dl').findActiveSlide();
	if(activeID < noMoreActiveID){
	this.parent('dl').find('dd.no-more-active').addClass('plus');
}
this.parent('dl').calculateSlidePos();
}
;
	jQuery.fn.rotateSlides = function(slideInterval,timerInstance){
	var accordianInstance = jQuery(this);
	timerInstance.value = setTimeout(function(){
	accordianInstance.rotateSlides(slideInterval,timerInstance);
}
,slideInterval);
	jQuery(this).findActiveSlide();
	var totalSlides = jQuery(this).find('dt').size();
	var activeSlide = activeID;
	var newSlide = activeSlide + 1;
	if (newSlide > totalSlides) newSlide = 1;
	jQuery(this).find('dt:eq(' + (newSlide-1) + ')').activateSlide();
	// activate the new slide}
// -------- Let's do it! ------------------------------------------------------------------------------function trackerObject(){
	this.value = null}
var timerInstance = new trackerObject();
	jQuery(this).findActiveSlide();
	jQuery(this).calculateSlidePos();
	if (settings.autoStart == true){
	var accordianInstance = jQuery(this);
	var interval = parseInt(settings.slideInterval);
	timerInstance.value = setTimeout(function(){
	accordianInstance.rotateSlides(interval,timerInstance);
}
,interval);
}
jQuery(this).find('dt').not('active').click(function(){
	jQuery(this).activateSlide();
	clearTimeout(timerInstance.value);
}
);
	if (!(jQuery.browser.msie && jQuery.browser.version == 6.0)){
	jQuery('dt').hover(function(){
	jQuery(this).addClass('hover');
}
,function(){
	jQuery(this).removeClass('hover');
}
);
}
}
);
}
;
}
)(jQuery);
	

JS代码(utility.js):

$(document).ready(function (){
	$('#accordion-1').easyAccordion({
	autoStart:true,slideInterval:3000}
);
	$('#accordion-2').easyAccordion({
	autoStart:false}
);
	$('#accordion-3').easyAccordion({
	autoStart:true,slideInterval:5000,slideNum:false}
);
	$('#accordion-4').easyAccordion({
	autoStart:false,slideInterval:5000}
);
}
);
	
附件:下载该文件资源,减少时间成本(增值服务)
留言
该资源可下载
File Source
.rar
249.50 KB
Html Js 手拉琴特效
最新结算
股权转让协议意向书模板
类型: .docx 金额: CNY 2.23¥ 状态: 待结算 详细>
股权转让协议意向书模板
类型: .docx 金额: CNY 0.28¥ 状态: 待结算 详细>
CSS3图片向上3D翻转渐隐消失特效
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
CSS3图片向上3D翻转渐隐消失特效
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
.net c# 将金额转人名币大写金额
类型: .rar 金额: CNY 2.39¥ 状态: 待结算 详细>
.net c# 将金额转人名币大写金额
类型: .rar 金额: CNY 0.3¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 2.23¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 0.28¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 2.23¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 0.28¥ 状态: 待结算 详细>
我们力求给您提供有用的文章,再此基础上,会附加营收资源,不做任何广告,让平台可以更好发展 若您发现您的权利被侵害,或使用了您的版权,请发邮件联系 sunlifel@foxmail.com ggbig觉得 : 不提供源码的文章不是好文章
合作伙伴
联系我们
  • QQ:21499807
  • 邮箱:sunlifel@foxmail.com
  • QQ扫一扫加QQ
    QQ扫一扫
Copyright 2023-2024 ggbig.com·皖ICP备2023004211号-1
打赏文章