菜单中的限制项目,单击下一步按钮时显示

时间:2017-02-24 07:55:11

标签: javascript jquery html css

我有一个菜单有很多项目。

我只想显示5个项目,其他项目将被隐藏。

点击下一个或上一个按钮时,它会显示其他项目。

应该这样显示:

enter image description here

这是我的演示代码:



// When we click on the LI
$("a").click(function(){
  // If this isn't already active
  if (!$(this).parent().hasClass("active")) {
    // Remove the class from anything that is active
    $("li.active").removeClass("active");
    // And make this active
    $(this).parent().addClass("active");
  }
});

$('a').click(function(e){
    e.stopPropagation();
});

var list = $("#list");
var li = list.children();
var lengthMinusOne = li.length - 1;
var index = 0;
var num = $("#list li").length;

var prevLi = $(li[0]);

$("#NextButton").click(function(){
   index++;
   if (index > lengthMinusOne) index = 0;
   prevLi.removeClass("active");
   prevLi = $(li[index]).addClass("active");
});
$("#PrevButton").click(function(){
   index--;
   if (index < 0) index = lengthMinusOne;
   prevLi.removeClass("active");
   prevLi = $(li[index]).addClass("active");
});
&#13;
/* General Demo Style */
body{
	font-family: Cambria, Palatino, "Palatino Linotype", "Palatino LT STD", Georgia, serif;
	/*background: #e0e3ec url(../images/bg.png) repeat top left;*/
	font-weight: 400;
	font-size: 15px;
	color: #593741;
	overflow-y: scroll;
}
a{
	color: #333;
	text-decoration: none;
}
.container{
	width: 100%;
	position: absolute; /*relative;*/
	text-align: center;
}
.clr{
	clear: both;
}
.container > header{
	padding: 20px 30px 10px 30px;
	margin: 0px 20px 10px 20px;
	position: relative;
	display: block;
	text-shadow: 1px 1px 1px rgba(0,0,0,0.2);
    text-align: center;
}
.container > header h1{
	font-family: 'BebasNeueRegular', 'Arial Narrow', Arial, sans-serif;
	font-size: 35px;
	line-height: 35px;
	position: relative;
	font-weight: 400;
	color: #936975;
	text-shadow: 1px 1px 1px rgba(0,0,0,0.3);
    padding: 0px 0px 5px 0px;
}
.container > header h1 span{
	color: #b19099;
	text-shadow: 0px 1px 1px rgba(255,255,255,0.8);
}
.container > header h2{
	font-size: 16px;
	font-style: italic;
	color: #593741;
	text-shadow: 0px 1px 1px rgba(255,255,255,0.8);
}
/* Header Style */
.codrops-top{
	line-height: 24px;
	font-size: 11px;
	background: rgba(255, 255, 255, 0.6);
	text-transform: uppercase;
	z-index: 9999;
	position: relative;
	box-shadow: 1px 0px 2px rgba(0,0,0,0.2);
}
.codrops-top a{
	padding: 0px 10px;
	letter-spacing: 1px;
	color: #333;
	text-shadow: 0px 1px 1px #fff;
	display: block;
	float: left;
}
.codrops-top a:hover{
	background: #fff;
}
.codrops-top span.right{
	float: right;
}
.codrops-top span.right a{
	float: left;
	display: block;
}

p.codrops-demos{
	text-align:center;
	display: block;
	padding: 14px;
}
p.codrops-demos a,
p.codrops-demos a.current-demo,
p.codrops-demos a.current-demo:hover{
    display: inline-block;
	border: 1px solid #b19099;
	padding: 4px 10px 3px;
	font-size: 13px;
	line-height: 18px;
	margin: 0px 3px;
	font-weight: 800;
	-webkit-box-shadow: 0px 1px 1px rgba(0,0,0,0.1);
	-moz-box-shadow:0px 1px 1px rgba(0,0,0,0.1);
	box-shadow: 0px 1px 1px rgba(0,0,0,0.1);
	color: #fff;
	text-shadow: 1px 1px 1px rgba(0,0,0,0.6);
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
	background: #b19099;
	background: -moz-linear-gradient(top, #b19099 0%, #936975 100%);
	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b19099), color-stop(100%,#936975));
	background: -webkit-linear-gradient(top, #b19099 0%,#936975 100%);
	background: -o-linear-gradient(top, #b19099 0%,#936975 100%);
	background: -ms-linear-gradient(top, #b19099 0%,#936975 100%);
	background: linear-gradient(top, #b19099 0%,#936975 100%);
	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b19099', endColorstr='#936975',GradientType=0 );
}
p.codrops-demos a:hover{
	background: #b19099;
}
p.codrops-demos a:active{
	-webkit-box-shadow: 0px 1px 1px rgba(255,255,255,0.4);
	-moz-box-shadow: 0px 1px 1px rgba(255,255,255,0.4);
	box-shadow: 0px 1px 1px rgba(255,255,255,0.4);
}
p.codrops-demos a.current-demo,
p.codrops-demos a.current-demo:hover{
	color: #443132;
	text-shadow: 0px 1px 1px rgba(255,255,255,0.3);
}
/*#testSlide3 {
	display: inline-block;
	border: 1px solid #b19099;
	padding: 4px 10px 3px;
	margin: 0px 3px;
	color: #fff;
	background: #111;
}*/
/* Media Queries */
@media screen and (max-width: 767px) {
	.container > header{
		text-align: center;
	}
	p.codrops-demos {
		position: relative;
		top: auto;
		left: auto;
	}
}
.da-slider{
	width: 100%;
	min-width: 520px;
	height: 768px; /*400px;*/
	position: relative;
	overflow: hidden;
	background: transparent url(../images/waves.gif) repeat 0% 0%;
	border-top: 8px solid #efc34a;
	border-bottom: 8px solid #efc34a;
	box-shadow: 0px 1px 1px rgba(0,0,0,0.2), 0px -2px 1px #fff;
	-webkit-transition: background-position 1.4s ease-in-out 0.3s;
	-moz-transition: background-position 1.4s ease-in-out 0.3s;
	-o-transition: background-position 1.4s ease-in-out 0.3s;
	-ms-transition: background-position 1.4s ease-in-out 0.3s;
	transition: background-position 1.4s ease-in-out 0.3s;
}
.da-slide{
	position: absolute;
	width: 100%;
	height: 100%;
	top: 0px;
	left: 0px;
	font-family: 'BebasNeueRegular', 'Arial Narrow', Arial, sans-serif;
	text-align: left;
}
.da-slide-current{
	z-index: 1000;
}
.da-slider-fb .da-slide{
	left: 100%;
}
.da-slider-fb  .da-slide.da-slide-current{
	left: 0px;
}
.da-slide h2,
.da-slide p,
.da-slide .da-link,
.da-slide .da-img{
	position: absolute;
	opacity: 0;
	left: 110%;
}
.da-slider-fb .da-slide h2,
.da-slider-fb .da-slide p,
.da-slider-fb .da-slide .da-link{
	left: 10%;
	opacity: 1;
}
.da-slider-fb .da-slide .da-img{
	left: 60%;
	opacity: 1;
}
.da-slide h2{
	color: #fff;
	font-size: 66px;
	width: 50%;
	top: 60px;
	white-space: nowrap;
	z-index: 10;
	text-shadow: 1px 1px 1px rgba(0,0,0,0.1);
	font-family: 'Economica', Arial, sans-serif;
	font-weight: 700;
}
.da-slide p{
	width: 45%;
	top: 155px;
	color: #916c05;
	font-size: 18px;
	line-height: 26px;
	height: 80px;
	overflow: hidden;
	font-style: italic;
	font-family: 'Economica', Arial, sans-serif;
	font-weight: 400;
	font-style: italic;
}
.da-slide .da-img{
	text-align: center;
	width: 30%;
	top: 70px;
	height: 256px;
	line-height: 320px;
	left: 110%; /*60%*/
}
.da-slide .da-link{
	top: 270px; /*depends on p height*/
	border-radius: 30px;
	box-shadow: 0px 1px 1px rgba(0,0,0,0.1);
	color: #fff;
	text-shadow: 1px 1px 1px rgba(0,0,0,0.2);
	border: 8px solid rgba(255,255,255,0.8);
	padding: 2px 20px 0px;
	font-size: 18px;
	line-height: 30px;
	width: 80px;
	text-align: center;
	background: rgba(255,255,255,0.2);
}
.da-slide .da-link:hover{
	background: rgba(255,255,255,0.3);
}
.da-dots{
	width: 100%;
	position: absolute;
	text-align: center;
	left: 0px;
	bottom: 20px;
	z-index: 2000;
	-moz-user-select: none;
	-webkit-user-select: none;
}
.da-dots span{
	display: inline-block;
	position: relative;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: #e4b42d;
	margin: 3px;
	cursor: pointer;
	box-shadow: 
		1px 1px 1px rgba(0,0,0,0.1) inset, 
		1px 1px 1px rgba(255,255,255,0.1);
}
.da-dots span.da-dots-current:after{
	content: '';
	width: 8px;
	height: 8px;
	position: absolute;
	top: 2px;
	left: 2px;
	border-radius: 50%;
	background: rgb(255,255,255);
	background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
	background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(47%,rgba(246,246,246,1)), color-stop(100%,rgba(237,237,237,1)));
	background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(246,246,246,1) 47%,rgba(237,237,237,1) 100%);
	background: -o-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(246,246,246,1) 47%,rgba(237,237,237,1) 100%);
	background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(246,246,246,1) 47%,rgba(237,237,237,1) 100%);
	background: linear-gradient(top, rgba(255,255,255,1) 0%,rgba(246,246,246,1) 47%,rgba(237,237,237,1) 100%);
	filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ededed',GradientType=0 );
}
.da-arrows{
	-moz-user-select: none;
	-webkit-user-select: none;
}
.da-arrows span{
	position: absolute;
	top: 50%;
	height: 30px;
	width: 30px;
	border-radius: 50%;
	background: #e4b42d;
	cursor: pointer;
	z-index: 2000;
	opacity: 0;
	box-shadow: 
		1px 1px 1px rgba(0,0,0,0.1) inset, 
		1px 1px 1px rgba(255,255,255,0.1);
	-webkit-transition: opacity 0.4s ease-in-out 0.2s;
	-moz-transition: opacity 0.4s ease-in-out 0.2s;
	-o-transition: opacity 0.4s ease-in-out 0.2s;
	-ms-transition: opacity 0.4s ease-in-out 0.2s;
	transition: opacity 0.4s ease-in-out 0.2s;
}
.da-slider:hover .da-arrows span{
	opacity: 1;
}
.da-arrows span:after{
	content: '';
	position: absolute;
	width: 20px;
	height: 20px;
	top: 5px;
	left: 5px;
	background: transparent url(../images/arrows.png) no-repeat top left;
	border-radius: 50%;
	box-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}
.da-arrows span:hover:after{
	box-shadow: 1px 1px 4px rgba(0,0,0,0.3);
}
.da-arrows span:active:after{
	box-shadow: 1px 1px 1px rgba(255,255,255,0.1);
}
.da-arrows span.da-arrows-next:after{
	background-position: top right;
}
.da-arrows span.da-arrows-prev{
	left: 15px;
}
.da-arrows span.da-arrows-next{
	right: 15px;
}

.da-slide-current h2,
.da-slide-current p,
.da-slide-current .da-link{
	left: 10%;
	opacity: 1;
}
.da-slide-current .da-img{
	left: 60%;
	opacity: 1;
}
/* Animation classes and animations */

/* Slide in from the right*/
.da-slide-fromright h2{
	-webkit-animation: fromRightAnim1 0.6s ease-in 0.8s both;
	-moz-animation: fromRightAnim1 0.6s ease-in 0.8s both;
	-o-animation: fromRightAnim1 0.6s ease-in 0.8s both;
	-ms-animation: fromRightAnim1 0.6s ease-in 0.8s both;
	animation: fromRightAnim1 0.6s ease-in 0.8s both;
}
.da-slide-fromright p{
	-webkit-animation: fromRightAnim2 0.6s ease-in 0.8s both;
	-moz-animation: fromRightAnim2 0.6s ease-in 0.8s both;
	-o-animation: fromRightAnim2 0.6s ease-in 0.8s both;
	-ms-animation: fromRightAnim2 0.6s ease-in 0.8s both;
	animation: fromRightAnim2 0.6s ease-in 0.8s both;
}
.da-slide-fromright .da-link{
	-webkit-animation: fromRightAnim3 0.4s ease-in 1.2s both;
	-moz-animation: fromRightAnim3 0.4s ease-in 1.2s both;
	-o-animation: fromRightAnim3 0.4s ease-in 1.2s both;
	-ms-animation: fromRightAnim3 0.4s ease-in 1.2s both;
	animation: fromRightAnim3 0.4s ease-in 1.2s both;
}
.da-slide-fromright .da-img{
	-webkit-animation: fromRightAnim4 0.6s ease-in 0.8s both;
	-moz-animation: fromRightAnim4 0.6s ease-in 0.8s both;
	-o-animation: fromRightAnim4 0.6s ease-in 0.8s both;
	-ms-animation: fromRightAnim4 0.6s ease-in 0.8s both;
	animation: fromRightAnim4 0.6s ease-in 0.8s both;
}
@-webkit-keyframes fromRightAnim1{
	0%{ left: 110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-webkit-keyframes fromRightAnim2{
	0%{ left: 110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-webkit-keyframes fromRightAnim3{
	0%{ left: 110%; opacity: 0; }
	1%{ left: 10%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-webkit-keyframes fromRightAnim4{
	0%{ left: 110%; opacity: 0; }
	100%{ left: 60%; opacity: 1; }
}

@-moz-keyframes fromRightAnim1{
	0%{ left: 110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-moz-keyframes fromRightAnim2{
	0%{ left: 110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-moz-keyframes fromRightAnim3{
	0%{ left: 110%; opacity: 0; }
	1%{ left: 10%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-moz-keyframes fromRightAnim4{
	0%{ left: 110%; opacity: 0; }
	100%{ left: 60%; opacity: 1; }
}

@-o-keyframes fromRightAnim1{
	0%{ left: 110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-o-keyframes fromRightAnim2{
	0%{ left: 110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-o-keyframes fromRightAnim3{
	0%{ left: 110%; opacity: 0; }
	1%{ left: 10%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-o-keyframes fromRightAnim4{
	0%{ left: 110%; opacity: 0; }
	100%{ left: 60%; opacity: 1; }
}

@-ms-keyframes fromRightAnim1{
	0%{ left: 110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-ms-keyframes fromRightAnim2{
	0%{ left: 110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-ms-keyframes fromRightAnim3{
	0%{ left: 110%; opacity: 0; }
	1%{ left: 10%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-ms-keyframes fromRightAnim4{
	0%{ left: 110%; opacity: 0; }
	100%{ left: 60%; opacity: 1; }
}

@keyframes fromRightAnim1{
	0%{ left: 110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@keyframes fromRightAnim2{
	0%{ left: 110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@keyframes fromRightAnim3{
	0%{ left: 110%; opacity: 0; }
	1%{ left: 10%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@keyframes fromRightAnim4{
	0%{ left: 110%; opacity: 0; }
	100%{ left: 60%; opacity: 1; }
}
/* Slide in from the left*/
.da-slide-fromleft h2{
	-webkit-animation: fromLeftAnim1 0.6s ease-in 0.6s both;
	-moz-animation: fromLeftAnim1 0.6s ease-in 0.6s both;
	-o-animation: fromLeftAnim1 0.6s ease-in 0.6s both;
	-ms-animation: fromLeftAnim1 0.6s ease-in 0.6s both;
	animation: fromLeftAnim1 0.6s ease-in 0.6s both;
}
.da-slide-fromleft p{
	-webkit-animation: fromLeftAnim2 0.6s ease-in 0.6s both;
	-moz-animation: fromLeftAnim2 0.6s ease-in 0.6s both;
	-o-animation: fromLeftAnim2 0.6s ease-in 0.6s both;
	-ms-animation: fromLeftAnim2 0.6s ease-in 0.6s both;
	animation: fromLeftAnim2 0.6s ease-in 0.6s both;
}
.da-slide-fromleft .da-link{
	-webkit-animation: fromLeftAnim3 0.4s ease-in 1.2s both;
	-moz-animation: fromLeftAnim3 0.4s ease-in 1.2s both;
	-o-animation: fromLeftAnim3 0.4s ease-in 1.2s both;
	-ms-animation: fromLeftAnim3 0.4s ease-in 1.2s both;
	animation: fromLeftAnim3 0.4s ease-in 1.2s both;
}
.da-slide-fromleft .da-img{
	-webkit-animation: fromLeftAnim4 0.6s ease-in 0.6s both;
	-moz-animation: fromLeftAnim4 0.6s ease-in 0.6s both;
	-o-animation: fromLeftAnim4 0.6s ease-in 0.6s both;
	-ms-animation: fromLeftAnim4 0.6s ease-in 0.6s both;
	animation: fromLeftAnim4 0.6s ease-in 0.6s both;
}
@-webkit-keyframes fromLeftAnim1{
	0%{ left: -110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-webkit-keyframes fromLeftAnim2{
	0%{ left: -110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-webkit-keyframes fromLeftAnim3{
	0%{ left: -110%; opacity: 0; }
	1%{ left: 10%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-webkit-keyframes fromLeftAnim4{
	0%{ left: -110%; opacity: 0; }
	100%{ left: 60%; opacity: 1; }
}

@-moz-keyframes fromLeftAnim1{
	0%{ left: -110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-moz-keyframes fromLeftAnim2{
	0%{ left: -110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-moz-keyframes fromLeftAnim3{
	0%{ left: -110%; opacity: 0; }
	1%{ left: 10%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-moz-keyframes fromLeftAnim4{
	0%{ left: -110%; opacity: 0; }
	100%{ left: 60%; opacity: 1; }
}

@-o-keyframes fromLeftAnim1{
	0%{ left: -110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-o-keyframes fromLeftAnim2{
	0%{ left: -110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-o-keyframes fromLeftAnim3{
	0%{ left: -110%; opacity: 0; }
	1%{ left: 10%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-o-keyframes fromLeftAnim4{
	0%{ left: -110%; opacity: 0; }
	100%{ left: 60%; opacity: 1; }
}

@-ms-keyframes fromLeftAnim1{
	0%{ left: -110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-ms-keyframes fromLeftAnim2{
	0%{ left: -110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-ms-keyframes fromLeftAnim3{
	0%{ left: -110%; opacity: 0; }
	1%{ left: 10%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@-ms-keyframes fromLeftAnim4{
	0%{ left: -110%; opacity: 0; }
	100%{ left: 60%; opacity: 1; }
}

@keyframes fromLeftAnim1{
	0%{ left: -110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@keyframes fromLeftAnim2{
	0%{ left: -110%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@keyframes fromLeftAnim3{
	0%{ left: -110%; opacity: 0; }
	1%{ left: 10%; opacity: 0; }
	100%{ left: 10%; opacity: 1; }
}
@keyframes fromLeftAnim4{
	0%{ left: -110%; opacity: 0; }
	100%{ left: 60%; opacity: 1; }
}
/* Slide out to the right */
.da-slide-toright h2{
	-webkit-animation: toRightAnim1 0.6s ease-in 0.6s both;
	-moz-animation: toRightAnim1 0.6s ease-in 0.6s both;
	-o-animation: toRightAnim1 0.6s ease-in 0.6s both;
	-ms-animation: toRightAnim1 0.6s ease-in 0.6s both;
	animation: toRightAnim1 0.6s ease-in 0.6s both;
}
.da-slide-toright p{
	-webkit-animation: toRightAnim2 0.6s ease-in 0.3s both;
	-moz-animation: toRightAnim2 0.6s ease-in 0.3s both;
	-o-animation: toRightAnim2 0.6s ease-in 0.3s both;
	-ms-animation: toRightAnim2 0.6s ease-in 0.3s both;
	animation: toRightAnim2 0.6s ease-in 0.3s both;
}
.da-slide-toright .da-link{
	-webkit-animation: toRightAnim3 0.4s ease-in both;
	-moz-animation: toRightAnim3 0.4s ease-in both;
	-o-animation: toRightAnim3 0.4s ease-in both;
	-ms-animation: toRightAnim3 0.4s ease-in both;
	animation: toRightAnim3 0.4s ease-in both;
}
.da-slide-toright .da-img{
	-webkit-animation: toRightAnim4 0.6s ease-in both;
	-moz-animation: toRightAnim4 0.6s ease-in both;
	-o-animation: toRightAnim4 0.6s ease-in both;
	-ms-animation: toRightAnim4 0.6s ease-in both;
	animation: toRightAnim4 0.6s ease-in both;
}
@-webkit-keyframes toRightAnim1{
	0%{ left: 10%;  opacity: 1; }
	100%{ left: 100%; opacity: 0; }
}
@-webkit-keyframes toRightAnim2{
	0%{ left: 10%;  opacity: 1; }
	100%{ left: 100%; opacity: 0; }
}
@-webkit-keyframes toRightAnim3{
	0%{ left: 10%;  opacity: 1; }
	99%{ left: 10%; opacity: 0; }
	100%{ left: 100%; opacity: 0; }
}
@-webkit-keyframes toRightAnim4{
	0%{ left: 60%;  opacity: 1; }
	30%{ left: 55%;  opacity: 1; }
	100%{ left: 100%; opacity: 0; }
}

@-moz-keyframes toRightAnim1{
	0%{ left: 10%;  opacity: 1; }
	100%{ left: 100%; opacity: 0; }
}
@-moz-keyframes toRightAnim2{
	0%{ left: 10%;  opacity: 1; }
	100%{ left: 100%; opacity: 0; }
}
@-moz-keyframes toRightAnim3{
	0%{ left: 10%;  opacity: 1; }
	99%{ left: 10%; opacity: 0; }
	100%{ left: 100%; opacity: 0; }
}
@-moz-keyframes toRightAnim4{
	0%{ left: 60%;  opacity: 1; }
	30%{ left: 55%;  opacity: 1; }
	100%{ left: 100%; opacity: 0; }
}

@-o-keyframes toRightAnim1{
	0%{ left: 10%;  opacity: 1; }
	100%{ left: 100%; opacity: 0; }
}
@-o-keyframes toRightAnim2{
	0%{ left: 10%;  opacity: 1; }
	100%{ left: 100%; opacity: 0; }
}
@-o-keyframes toRightAnim3{
	0%{ left: 10%;  opacity: 1; }
	99%{ left: 10%; opacity: 0; }
	100%{ left: 100%; opacity: 0; }
}
@-o-keyframes toRightAnim4{
	0%{ left: 60%;  opacity: 1; }
	30%{ left: 55%;  opacity: 1; }
	100%{ left: 100%; opacity: 0; }
}

@-ms-keyframes toRightAnim1{
	0%{ left: 10%;  opacity: 1; }
	100%{ left: 100%; opacity: 0; }
}
@-ms-keyframes toRightAnim2{
	0%{ left: 10%;  opacity: 1; }
	100%{ left: 100%; opacity: 0; }
}
@-ms-keyframes toRightAnim3{
	0%{ left: 10%;  opacity: 1; }
	99%{ left: 10%; opacity: 0; }
	100%{ left: 100%; opacity: 0; }
}
@-ms-keyframes toRightAnim4{
	0%{ left: 60%;  opacity: 1; }
	30%{ left: 55%;  opacity: 1; }
	100%{ left: 100%; opacity: 0; }
}

@keyframes toRightAnim1{
	0%{ left: 10%;  opacity: 1; }
	100%{ left: 100%; opacity: 0; }
}
@keyframes toRightAnim2{
	0%{ left: 10%;  opacity: 1; }
	100%{ left: 100%; opacity: 0; }
}
@keyframes toRightAnim3{
	0%{ left: 10%;  opacity: 1; }
	99%{ left: 10%; opacity: 0; }
	100%{ left: 100%; opacity: 0; }
}
@keyframes toRightAnim4{
	0%{ left: 60%;  opacity: 1; }
	30%{ left: 55%;  opacity: 1; }
	100%{ left: 100%; opacity: 0; }
}
/* Slide out to the left*/
.da-slide-toleft h2{
	-webkit-animation: toLeftAnim1 0.6s ease-in both;
	-moz-animation: toLeftAnim1 0.6s ease-in both;
	-o-animation: toLeftAnim1 0.6s ease-in both;
	-ms-animation: toLeftAnim1 0.6s ease-in both;
	animation: toLeftAnim1 0.6s ease-in both;
}
.da-slide-toleft p{
	-webkit-animation: toLeftAnim2 0.6s ease-in 0.3s both;
	-moz-animation: toLeftAnim2 0.6s ease-in 0.3s both;
	-o-animation: toLeftAnim2 0.6s ease-in 0.3s both;
	-ms-animation: toLeftAnim2 0.6s ease-in 0.3s both;
	animation: toLeftAnim2 0.6s ease-in 0.3s both;
}
.da-slide-toleft .da-link{
	-webkit-animation: toLeftAnim3 0.4s ease-in both;
	-moz-animation: toLeftAnim3 0.4s ease-in both;
	-o-animation: toLeftAnim3 0.4s ease-in both;
	-ms-animation: toLeftAnim3 0.4s ease-in both;
	animation: toLeftAnim3 0.4s ease-in both;
}
.da-slide-toleft .da-img{
	-webkit-animation: toLeftAnim4 0.6s ease-in 0.6s both;
	-moz-animation: toLeftAnim4 0.6s ease-in 0.6s both;
	-o-animation: toLeftAnim4 0.6s ease-in 0.6s both;
	-ms-animation: toLeftAnim4 0.6s ease-in 0.6s both;
	animation: toLeftAnim4 0.6s ease-in 0.6s both;
}
@-webkit-keyframes toLeftAnim1{
	0%{ left: 10%;  opacity: 1; }
	30%{ left: 15%;  opacity: 1; }
	100%{ left: -50%; opacity: 0; }
}
@-webkit-keyframes toLeftAnim2{
	0%{ left: 10%;  opacity: 1; }
	30%{ left: 15%;  opacity: 1; }
	100%{ left: -50%; opacity: 0; }
}
@-webkit-keyframes toLeftAnim3{
	0%{ left: 10%;  opacity: 1; }
	99%{ left: 10%; opacity: 0; }
	100%{ left: -50%; opacity: 0; }
}
@-webkit-keyframes toLeftAnim4{
	0%{ left: 60%;  opacity: 1; }
	40%{ left: 70%;  opacity: 1; }
	90%{ left: 0%;  opacity: 0; }
	100%{ left: -50%; opacity: 0; }
}

@-moz-keyframes toLeftAnim1{
	0%{ left: 10%;  opacity: 1; }
	30%{ left: 15%;  opacity: 1; }
	100%{ left: -50%; opacity: 0; }
}
@-moz-keyframes toLeftAnim2{
	0%{ left: 10%;  opacity: 1; }
	30%{ left: 15%;  opacity: 1; }
	100%{ left: -50%; opacity: 0; }
}
@-moz-keyframes toLeftAnim3{
	0%{ left: 10%;  opacity: 1; }
	99%{ left: 10%; opacity: 0; }
	100%{ left: -50%; opacity: 0; }
}
@-moz-keyframes toLeftAnim4{
	0%{ left: 60%;  opacity: 1; }
	40%{ left: 70%;  opacity: 1; }
	90%{ left: 0%;  opacity: 0; }
	100%{ left: -50%; opacity: 0; }
}

@-o-keyframes toLeftAnim1{
	0%{ left: 10%;  opacity: 1; }
	30%{ left: 15%;  opacity: 1; }
	100%{ left: -50%; opacity: 0; }
}
@-o-keyframes toLeftAnim2{
	0%{ left: 10%;  opacity: 1; }
	30%{ left: 15%;  opacity: 1; }
	100%{ left: -50%; opacity: 0; }
}
@-o-keyframes toLeftAnim3{
	0%{ left: 10%;  opacity: 1; }
	99%{ left: 10%; opacity: 0; }
	100%{ left: -50%; opacity: 0; }
}
@-o-keyframes toLeftAnim4{
	0%{ left: 60%;  opacity: 1; }
	40%{ left: 70%;  opacity: 1; }
	90%{ left: 0%;  opacity: 0; }
	100%{ left: -50%; opacity: 0; }
}

@-ms-keyframes toLeftAnim1{
	0%{ left: 10%;  opacity: 1; }
	30%{ left: 15%;  opacity: 1; }
	100%{ left: -50%; opacity: 0; }
}
@-ms-keyframes toLeftAnim2{
	0%{ left: 10%;  opacity: 1; }
	30%{ left: 15%;  opacity: 1; }
	100%{ left: -50%; opacity: 0; }
}
@-ms-keyframes toLeftAnim3{
	0%{ left: 10%;  opacity: 1; }
	99%{ left: 10%; opacity: 0; }
	100%{ left: -50%; opacity: 0; }
}
@-ms-keyframes toLeftAnim4{
	0%{ left: 60%;  opacity: 1; }
	40%{ left: 70%;  opacity: 1; }
	90%{ left: 0%;  opacity: 0; }
	100%{ left: -50%; opacity: 0; }
}

@keyframes toLeftAnim1{
	0%{ left: 10%;  opacity: 1; }
	30%{ left: 15%;  opacity: 1; }
	100%{ left: -50%; opacity: 0; }
}
@keyframes toLeftAnim2{
	0%{ left: 10%;  opacity: 1; }
	30%{ left: 15%;  opacity: 1; }
	100%{ left: -50%; opacity: 0; }
}
@keyframes toLeftAnim3{
	0%{ left: 10%;  opacity: 1; }
	99%{ left: 10%; opacity: 0; }
	100%{ left: -50%; opacity: 0; }
}
@keyframes toLeftAnim4{
	0%{ left: 60%;  opacity: 1; }
	40%{ left: 70%;  opacity: 1; }
	90%{ left: 0%;  opacity: 0; }
	100%{ left: -50%; opacity: 0; }
}
#cssmenu ul {
  margin: 0;
  padding: 0;
  list-style-type: none;
  width: 1366px;
  position: relative;
  display: block;
  font-size: 12px;
  font-weight: bold;
  background: #f2f1f2;
  font-family: Arial, Helvetica, sans-serif;
  border-bottom: 1px solid #f2f1f2;
  zoom: 1;
}
#cssmenu ul:before {
  content: '';
  display: block;
}
#cssmenu ul:after {
  content: '';
  display: table;
  clear: both;
}
#cssmenu li {
  display: block;
  float: left;
  margin: 0;
  padding: 0 4px;
}
#cssmenu li a {
  display: block;
  float: left;
  color: #797978;
  text-decoration: none;
  font-weight: bold;
  padding: 10px 20px 7px 20px;
  border-bottom: 3px solid transparent;
}
#cssmenu li a:hover {
  color: #6c8cb5;
  border-bottom: 3px solid #00b8fd;
}
#cssmenu li.active a {
  display: inline;
  border-bottom: 3px solid #00b8fd;
  float: left;
  margin: 0;
}
&#13;
<div id="cssmenu">
  <ul id="list">
    <li class='active'><a id="testSlide1" href='#'><span>Home</span></a></li>
    <li><a id="testSlide2" href='#'><span>Products</span></a></li>
    <li><a id="testSlide3" href='#'><span>About</span></a></li>
    <li><a id="testSlide4" href='#'><span>Contact</span></a></li>
    <li><a id="testSlide5" href='#'><span>Blog</span></a></li>
    <li><a id="testSlide6" href='#'><span>Forum</span></a></li>
    <li><a id="testSlide7" href='#'><span>Chat</span></a></li>
    <li><a id="testSlide8" href='#'><span>Gem</span></a></li>
  </ul>
</div>
<nav class="da-arrows">
  <button id="PrevButton">Previous</button>
  <button id="NextButton">Next</button>
</nav>
&#13;
&#13;
&#13;

或者JsFiddle在这里:http://jsfiddle.net/tJ9aj/5/

2 个答案:

答案 0 :(得分:4)

添加CSS类

.hide {
  display:none!important;
}

HTML代码:

...
<li class="hide"><a id="testSlide5" href='#'><span>Blog</span></a></li>
<li class="hide"><a id="testSlide6" href='#'><span>Forum</span></a></li>
<li class="hide"><a id="testSlide7" href='#'><span>Chat</span></a></li>
<li class="hide"><a id="testSlide8" href='#'><span>Gem</span></a></li>
...

JS代码:

$("#NextButton").click(function(){
   index++;
   li.removeClass("hide");    // Added this line
   if (index > lengthMinusOne) index = 0;
   prevLi.removeClass("active");
   prevLi = $(li[index]).addClass("active");
});

JsFiddle

答案 1 :(得分:2)

更新了小提琴:http://jsfiddle.net/tJ9aj/8/

开始时:

$('#testSlide6').hide();
$('#testSlide7').hide();
$('#testSlide8').hide();

如果您点击上一个或下一个:

$("#NextButton").click(function(){
   index++;
   if (index > lengthMinusOne) index = 0;
   prevLi.removeClass("active");
   prevLi = $(li[index]).addClass("active");

   $('#testSlide6').show();
   $('#testSlide7').show();
   $('#testSlide8').show();
});

$("#PrevButton").click(function(){
   index--;
   if (index < 0) index = lengthMinusOne;
   prevLi.removeClass("active");
   prevLi = $(li[index]).addClass("active");
   $('#testSlide6').show();
   $('#testSlide7').show();
   $('#testSlide8').show();
});