<!doctype html>
<html>
<head>
<meta charset=
"UTF-8"
>
<meta name=
"viewport"
content=
"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
>
<meta http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
>
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
}
ul {
list-style-type: none;
height: 42px;
position: absolute;
}
img {
vertical-align: middle;
}
li,
a {
cursor: pointer;
}
a {
text-decoration: none;
color:
#000000;
display: block;
}
li {
width: 83px;
height: 42px;
float: left;
text-align: center;
line-height: 42px;
}
.box {
position: relative;
width: 530px;
height: 42px;
border: 1px solid deepskyblue;
margin: 100px auto;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
.box img
#cloud {
width: 83px;
height: 42px;
position: absolute;
left: 0;
top: 0;
}
.box img
#xinhao {
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
}
</style>
</head>
<body>
<div id=
"box"
>
<img id=
"cloud"
src=
"images/cloud.gif"
alt=
""
/>
<ul id=
"ull"
>
<li><a href=
"#"
>长沙校区</a></li>
<li><a href=
"#"
>长沙校区</a></li>
<li><a href=
"#"
>长沙校区</a></li>
<li><a href=
"#"
>长沙校区</a></li>
<li><a href=
"#"
>长沙校区</a></li>
<li><a href=
"#"
>长沙校区</a></li>
</ul>
<img id=
"xinhao"
src=
"images/rss.png"
alt=
""
/>
</div>
<script src=
"js/common.js"
></script>
<script src=
"js/changespead.js"
></script>
<script>
var
list=my$(
'ull'
).children;
console.log(list);
var
im=my$(
'cloud'
);
var
imgWidth=im.offsetWidth;
console.log(imgWidth);
for
(
var
i=0;i<list.length;i++){
list[i].setAttribute(
'index'
,i);
list[i].onmouseover=f1;
list[i].onmouseout=f1;
list[i].onclick=f1;
function
f1(e){
switch
(e.type) {
case
'mouseover'
:
index=
this
.getAttribute(
'index'
);
movecs(im,imgWidth*index);
break
;
case
'click'
:
index=
this
.getAttribute(
'index'
);
im.style.left=imgWidth*index+
'px'
;
this
.onmouseout=
false
;
for
(
var
k=0;k<list.length;k++){
list[k].setAttribute(
'jndex'
,k);
list[k].onmouseover=
function
(){
jndex=
this
.getAttribute(
'jndex'
);
movecs(im,imgWidth*jndex);
};
list[k].onmouseout=
function
(){
movecs(im,imgWidth*index);
};
}
break
;
case
'mouseout'
:
index=0;
movecs(im,imgWidth*index);
break
;
}
}
}
</script>
</body>
</html>