<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>tab tab an exercise </title>
<style>
*{
margin:0px;
padding:0px;
}
#tab {
width:400px;
height:250px;
margin:20px Auto;
position:relative;
}
#tab #item {
width:370px;
border:1px solid #ccc;
height:31px;
line-height:31px;
Border-right:none;
}
#tab #item li{
width:40px;
height:28px;
line-height:28px;
font-size:14px;
Text-align:center;
List-style:none;
Float:left;
PADDING:2PX 0px;
Border-right:solid 1px #ccc;
}
#tab #item Li a{
Text-decoration:none;
Color: #000;
}
#tab. box{
width:370px;
height:100%;
position:relative;
Overflow:hidden;
Z-index:1;
}
#tab. Box #picTxtBox {
width:1000%;
Position:absolute;
top:0px;
left:0px;
}
#tab. Box #picTxtBox li{
List-style:none;
Float:left;
}
img{
width:400px;
height:250px;
}
#tab. Box #picTxtBox. text{
Position:absolute;
bottom:0px;
left:0px;
Background: #000;
opacity:0.08;
width:100%;
height:40px;
Color:white;
line-height:40px;
font-size:14px;
padding-left:10px;
}
. box. btnleft{
Position:absolute;
top:40%;
left:20px;
color:red;
font-size:40px;
z-index:999;
Font-weight:bolder;
Font-family: blackbody;
Text-decoration:none;
Display:none;
Background: #cccccc;
width:40px;
Text-align:center;
opacity:0.3;
}
. box. btnright{
Position:absolute;
top:40%;
right:20px;
color:red;
font-size:40px;
z-index:999;
Font-weight:bolder;
Font-family: blackbody;
Text-decoration:none;
Display:none;
Background: #cccccc;
width:40px;
Text-align:center;
opacity:0.3;
}
. active{
Background:royalblue;
}
</style>
<script>
Window.onload=function () {
var otab = document.getElementById ("tab");
var oitem = document.getElementById ("item");
var oLi = oitem.getelementsbytagname ("Li");
var opictxtbox = document.getElementById ("Pictxtbox");
var Opictxtli = opictxtbox.getelementsbytagname ("Li");
var obtnleft = document.getElementById ("Btnleft");
var obtnright = document.getElementById ("Btnright");
var inow=0;
for (Var i=0;i<oli.length;i++) {
Oli[i].index = i;
Oli[i].onmouseover=function () {
Inow = This.index;
Move (Inow);
}
}
Otab.onmouseover = function () {
OBtnLeft.style.display = "block";
OBtnRight.style.display = "block";
}
Otab.onmouseout = function () {
OBtnLeft.style.display = "None";
OBtnRight.style.display = "None";
}
Obtnright.onclick=function () {
inow++;
if (inow>oli.length-1) {
Inow = 0;
}
Move (Inow);
alert (Inow);
for (Var n=0;n<oli.length;n++) {
Opictxtli[n].style.display = "None";
Oli[n].classname = "";
}
Document.title = "The current index is =" +inow;
Opictxtli[inow].style.display = "block";
Oli[inow].classname = "active";
};
Obtnleft.onclick=function () {
inow--;
if (inow<0) {
Inow = oli.length-1;
}
};
Encapsulated functions
function Move (index) {
for (Var n=0;n<oli.length;n++) {
Opictxtli[n].style.display = "None";
Oli[n].classname = "";
}
Document.title = "The current index is =" +inow;
Opictxtli[inow].style.display = "block";
Oli[inow].classname = "active";
}
}
</script>
<body>
<div id= "tab" >
<div class= "Item" id= "Item" >
<li class= "Active" ><a href= "javascript:void (0);" > News </a></li>
<li><a href= "javascript:void (0);" > Entertainment </a></li>
<li><a href= "javascript:void (0);" > Sports </a></li>
<li><a href= "javascript:void (0);" > Automotive </a></li>
<li><a href= "javascript:void (0);" > Fashion </a></li>
<li><a href= "javascript:void (0);" > History </a></li>
<li><a href= "javascript:void (0);" > Kee </a></li>
<li><a href= "javascript:void (0);" > Boutique </a></li>
<li><a href= "javascript:void (0);" > Games </a></li>
</div>
<div class= "box" >
<a class= "Btnleft" id= "Btnleft" href= "javascript:void (0)" ><</a>
<a class= "Btnright" id= "Btnright" href= "javascript:void (0)" >></a>
<ul id= "Pictxtbox" >
<li style= "Display:block" >
<a href= "javascript:void (0);" ></a>
<p class= "Keep" > </p>
<p class= "text" > Guangzhou burst Fire </p>
</li>
<li>
<a href= "javascript:void (0);" ></a>
<p class= "Keep" > </p>
<p class= "text" > Boutique </p>
</li>
<li>
<a href= "javascript:void (0);" ></a>
<p class= "Keep" > </p>
<p class= "text" > because of this picture </p>
</li>
<li>
<a href= "javascript:void (0);" ></a>
<p class= "Keep" > </p>
<p class= "text" > Asian women's Volleyball </p>
</li>
<li>
<a href= "javascript:void (0);" ></a>
<p class= "Keep" > </p>
<p class= "text" > Guangzhou luxury Car </p>
</li>
<li>
<a href= "javascript:void (0);" ></a>
<p class= "Keep" > </p>
<p class= "text" > Olympic champions </p>
</li>
<li>
<a href= "javascript:void (0);" ></a>
<p class= "Keep" > </p>
<p class= "Text" > Military secrets </p>
</li>
<li>
<a href= "javascript:void (0);" ></a>
<p class= "Keep" > </p>
<p class= "text" > Real estate </p>
</li>
<li>
<a href= "javascript:void (0);" ></a>
<p class= "Keep" > </p>
<p class= "text" > Games </p>
</li>
</ul>
</div>
</div>
</body>
Tab tab code (native JS)