网页常用动态效果--客服广告

王朝学院·作者佚名  2016-08-27
窄屏简体版  字體: 小  |  中  |  大  |  超大  

关键在于设定开关标识,父盒子固定定位,按钮盒子绝对定位超出父盒子部分

html代码:

<div>

<img src="images/QQ.jpg" height="311" width="131" alt="">

<span><img src="images/qqL.jpg" height="117" width="29" alt=""></span>

</div>

CSS代码:

div{

width:131px;

height:311px;

background: lightseagreen;

position: fixed;

right:-131px;

top:50%;

margin-top:-155px;

}

div span{

position: absolute;

left:-29px;

top:50%;

cursor: pointer;

margin-top:-58px;

}

JQ代码:

<script>$(function(){//开关按钮,有两个状态,首先有一个初始状态varflag=1;

$('div span').on('click',function(){if(flag==1){

$(this).parent().animate({right:0},500);

$(this).children('img').attr('src','images/qqLOpen.jpg');

flag=0;

}elseif(flag==0){

$(this).parent().animate({right:-131},500);

$(this).children('img').attr('src','images/qqL.jpg');

flag=1;

}

})

})</script>

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝網路 版權所有 導航