焦点图片切换效果 兼容ie6 ie7 ff

<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
http://www.corange.cn//uploadfiles/090101_47974.jpg

1.对焦点图片下方进行透明处理.兼容ie6 ie7 ff透明效果
2.通过鼠标移动到不同的四小图片时,通过改变图片所处父节点id=focus_change_list的left值取得效果
3.默认下每5秒执行一次函数autoFocusChange(),来实现图片自动变换
<!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 type="text/css">
/* Reset style */
* { margin:0; padding:0; word-break:break-all; }
body { background:#FFF; color:#333; font:12px/1.6em Helvetica, Arial, sans-serif; }
h1, h2, h3, h4, h5, h6 { font-size:1em; }
a { color:#039; text-decoration:none; }
        a:hover { text-decoration:underline; }
ul, li { list-style:none; }
fieldset, img { border:none; }
em, strong, cite, th { font-style:normal; font-weight:normal; }
/* Focus_change style */
#focus_change { position:relative; width:450px; height:295px; overflow:hidden; margin:20px 0 1px 60px; }
        #focus_change_list { position:absolute; width:1800px; height:295px; }
                #focus_change_list li { float:left; }
                #focus_change_list li img { width:450px; height:295px; }
        .focus_change_opacity { position:absolute; width:450px; height:70px; top:225px; left:0; background:#000; filter:alpha(opacity=50); -moz-opacity:0.5; opacity: 0.5; }
        #focus_change_btn { position:absolute; width:450px; height:65px; top:225px; left:0; }
                #focus_change_btn ul { padding-left:5px; }
                #focus_change_btn li { display:inline; float:left; margin:0 15px; padding-top:12px; }
                #focus_change_btn li img { width:76px; height:50px; border:2px solid #888; }
                #focus_change_btn .current { background:url(http://www.byzuo.cn/demo/focus_change/img/icon_arrow.gif) no-repeat 37px 8px;}
                #focus_change_btn .current img { border-color:#EEE; }
</style>
<script type="text/javascript">
function $(id) { return document.getElementById(id); }
function moveElement(elementID,final_x,final_y,interval) {
  if (!document.getElementById) return false;
  if (!document.getElementById(elementID)) return false;
  var elem = document.getElementById(elementID);
  if (elem.movement) {
    clearTimeout(elem.movement);
  }
  if (!elem.style.left) {
    elem.style.left = "0px";
  }
  if (!elem.style.top) {
    elem.style.top = "0px";
  }
  var xpos = parseInt(elem.style.left);
  var ypos = parseInt(elem.style.top);
  if (xpos == final_x && ypos == final_y) {
                return true;
  }
  if (xpos < final_x) {
    var dist = Math.ceil((final_x - xpos)/10);
    xpos = xpos + dist;
  }
  if (xpos > final_x) {
    var dist = Math.ceil((xpos - final_x)/10);
    xpos = xpos - dist;
  }
  if (ypos < final_y) {
    var dist = Math.ceil((final_y - ypos)/10);
    ypos = ypos + dist;
  }
  if (ypos > final_y) {
    var dist = Math.ceil((ypos - final_y)/10);
    ypos = ypos - dist;
  }
  elem.style.left = xpos + "px";
  elem.style.top = ypos + "px";
  var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
  elem.movement = setTimeout(repeat,interval);
}
function classNormal(){
        var focusBtnList = $('focus_change_btn').getElementsByTagName('li');
        for(var i=0; i<focusBtnList.length; i++) {
                focusBtnList[i].className='';
        }
}
function focusChange() {
        var focusBtnList = $('focus_change_btn').getElementsByTagName('li');
                focusBtnList[0].onmouseover = function() {
                        moveElement('focus_change_list',0,0,5);
                        classNormal()
                        focusBtnList[0].className='current'
                }
                focusBtnList[1].onmouseover = function() {
                        moveElement('focus_change_list',-450,0,5);
                        classNormal()
                        focusBtnList[1].className='current'
                }
                focusBtnList[2].onmouseover = function() {
                        moveElement('focus_change_list',-900,0,5);
                        classNormal()
                        focusBtnList[2].className='current'
                }
                focusBtnList[3].onmouseover = function() {
                        moveElement('focus_change_list',-1350,0,5);
                        classNormal()
                        focusBtnList[3].className='current'
                }
}
setInterval('autoFocusChange()', 5000);
function autoFocusChange() {
        var focusBtnList = $('focus_change_btn').getElementsByTagName('li');
        for(var i=0; i<focusBtnList.length; i++) {
                if (focusBtnList[i].className == 'current') {
                        var currentNum = i;
                }
        }
        if (currentNum==0 ){
                moveElement('focus_change_list',-450,0,5);
                classNormal()
                focusBtnList[1].className='current'
        }
        if (currentNum==1 ){
                moveElement('focus_change_list',-900,0,5);
                classNormal()
                focusBtnList[2].className='current'
        }
        if (currentNum==2 ){
                moveElement('focus_change_list',-1350,0,5);
                classNormal()
                focusBtnList[3].className='current'
        }        
        if (currentNum==3 ){
                moveElement('focus_change_list',0,0,5);
                classNormal()
                focusBtnList[0].className='current'
        }
}
window.οnlοad=function(){
        focusChange();
}
</script>
</head>
<body>
<div id="focus_change">
        <div id="focus_change_list" style="top:0; left:0;">
                <ul>
                <li><img src="focus_change/img/01.jpg" alt="" /></li>
                <li><img src="focus_change/img/02.jpg" alt="" /></li>
                <li><img src="focus_change/img/03.jpg" alt="" /></li>
                <li><img src="focus_change/img/04.jpg" alt="" /></li>
                </ul>
        </div>
        <div class="focus_change_opacity"></div>
        <div id="focus_change_btn">
                <ul>
                <li class="current"><a href="#"><img src="focus_change/img/btn_01.jpg" alt="" /></a></li>
                <li><a href="#"><img src="focus_change/img/btn_02.jpg" alt="" /></a></li>
                <li><a href="#"><img src="focus_change/img/btn_03.jpg" alt="" /></a></li>
                <li><a href="#"><img src="focus_change/img/btn_04.jpg" alt="" /></a></li>
                </ul>
        </div>
</div>
</body>
</html>
http://www.corange.cn/archives/2008/09/1585.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值