完整的html+css+javascript实现跟随鼠标移动显示选中效果

1,显示效果:

2,html结构

 1             <div class="process_list-lpu">
 2                 <div class="process_line"></div>
 3                 <div class="content_list">
 4                     <ul>
 5                         <li><a href="javascipt:;">End customer get product<b>1</b></a> </li>
 6                         <li><a href="javascipt:;">Log in EFOSE website and present installation or maintenance requirements <b>2</b></a></li>
 7                         <li><a href="javascipt:;">EFOSE prefer contact service point<b>3</b></a> </li>
 8                         <li style="margin-left:115px;"><a href="javascipt:;">Customer contact service point to get service<b>4</b></a> </li>
 9                         <li><a href="javascipt:;">Customer pays the bill directly or EFOSE pays the maintenance cost<b>5</b></a> </li>
10                     </ul>
11                     <div class="clear"></div>
12                 </div>
13
14             </div>

3,主要的css样式

.line-lpu{ height:55px; position:relative; width:100%; overflow:hidden;}
    .line-lpu span{ width:43px; height:46px; background:url(‘https://www.efose.com/images/banners/lpu_03.png‘) no-repeat; position:absolute;top:0;}
    .border-lpu{border-bottom:1px  solid #959595; height:23px; }
     .join-lpu li{ width:19%; float:left; margin-right:8px;background:none; padding:0; }
    .join-lpu li a{ display:block; color:#606060; text-decoration:none; border:1px solid #959595; min-height:215px; padding:10px;position:relative; overflow:hidden;}
    .join-lpu li a:hover{border:1px solid #337ab7;}
    .join-lpu li b{ font-size:60px; position:absolute; bottom:7px; right:-1px; font-style:italic; color:#c7c7c7;}
    .clear{clear:both;}
    .step-lpu span{ background:url(‘https://www.efose.com/images/banners/icon-lpu.png‘) no-repeat; display:block; width:75px; height:65px; margin-left:28px;}
    .step-lpu .icon0{ background-position:0 0;}
    .step-lpu .icon1{ background-position:0 -70px;}
    .step-lpu .icon2{ background-position:0 -140px;}
    .step-lpu .icon3{ background-position:0 -204px; height:58px; margin-bottom:7px;}
    .step-lpu .icon4{ background-position:0 -260px;}

4,JavaScript的编写

 1 <script type="text/javascript">
 2         //实例化animationHover对象
 3         window.onload = function(){
 4             var ah = new animationHover();
 5             ah.init();
 6         };
 7         //初始化标签对象
 8         function animationHover(){
 9             this.step = document.getElementById(‘step‘);
10             this.stepLi = this.step.getElementsByTagName(‘li‘);
11             this.line = document.getElementById(‘line‘);
12             this.attr = null;
13             this.timer = null;
14             this.target = null;
15
16             }
17         //初始化事件
18         animationHover.prototype.init=function(){
19             This =this;
20             for(var i=0;i<this.stepLi.length;i++){
21                 this.stepLi[i].index=i;
22                 //给li标签绑定事件
23                 this.stepLi[i].onmouseover=function(e){
24                     var myIndex=this.index;
25                     This.onOver(This.line,(myIndex*162+55));
26                     };
27                 this.stepLi[i].onmouseout=function(){
28                    This.line.style.left=myIndex*162+55+‘px‘;
29                     };
30
31                 }
32             };
33         //定义鼠标经过的处理函数
34         animationHover.prototype.onOver=function(obj,target){
35             This=this;
36             clearInterval(this.timer);
37             This.target=target;
38             timer=setInterval(function(){
39                 var target=This.target; //停止的目标点
40                 var attrValue=parseInt(This.getStyle(obj,‘left‘));
41                 var dx=target-attrValue; //距目标点的"路程"
42                 var speed=1/10*dx;
43                 speed=speed>0?Math.ceil(speed):Math.floor(speed);
44                             //防止取整引起的抖动
45                 if(target==attrValue) clearInterval(timer);
46                             //如果到达目标点,关闭定时器
47                 else{
48                     obj.style.left=attrValue+speed+‘px‘;
49                 }
50                 },100);
51
52             };
53         //获取当前标签对象的css属性值
54         animationHover.prototype.getStyle =function(obj,attr){
55             if(obj.currentStyle){
56                 return obj.currentStyle[attr];
57             }else{
58                 return getComputedStyle(obj,false)[attr];
59             }
60             };
61
62
63
64
65 </script>
时间: 2024-08-25 05:15:24

完整的html+css+javascript实现跟随鼠标移动显示选中效果的相关文章

使用JavaScript实现使用鼠标画线的效果

<!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-

CSS3跟随鼠标的眼睛转动效果

<!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-

div跟随鼠标悬浮显示

<span style="font-size:18px;"><!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author"

javascript元素跟随鼠标在指定区域运动

元素跟随鼠标在指定区域运动通常是用在商城图片的放大镜中,下面是完整的Demo: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>鼠标区域</title> <style type="text/css"> *{margin:0;padding:0;} .area{ width:

关于wpf中popup跟随鼠标移动显示

最近在做一个画图工具,里面有一个功能是需要实现,当鼠标移动的时候在,鼠标的旁边显示坐标信息. 第一反应是想到了tooltip,但是tooltip有许多的限制,查询资料的过程中看到了popup,popup比tooltip更加灵活,下面讲讲tooltip跟popup的区别: 1.tooltip会自动显示,自动隐藏,而popup则需要设置IsOpen属性,并且在Popup.StaysOen属性为true时,Popup控件会一直显示,直到显式地将IsOpen属性设置为False.当Popup.Stays

javascript创建跟随鼠标好玩的东西

不说话,直接上代码. css: #createGoDivBox{ display: none; } #createGoDivBox div{ background-color: #00A6C2; position: absolute; border-radius: 50%; } js: init(); function init(){ // 获取body var parBox = document.body || document.getElementsByTagName('body')[0];

浅谈CSS和JQuery实现鼠标悬浮图片放大效果

对于刚刚学习网页前台设计的同学一定对图片的处理非常苦恼,那么这里简单的讲解一下几个图片处理的实例. 以.net为平台,微软的Visual Studio 2013为开发工具,当然前台技术还是采用CSS3和HTML,Java的小伙伴不要绕道~~~ 言归正传,那么我们首先要完成什么样的图片处理呢? 一.CSS3图片的放大 css3中,有一个属性transform,官方的解释是:允许向元素应用2D或3D的转换.这些转换当然就包含旋转.缩放.移动或倾斜了.有兴趣的同学可以继续了解http://www.w3

跟随鼠标的旋转文字效果

脚本说明: 把如下代码加入<body>区域中 <script language="JavaScript"> <!-- yourLogo='http://www.CsrCode.cn/'; logoFont='Arial'; logoSize=1; // 1-7 only! for larger font sizes alter logoWidth/Height accordingly! logoColor='811188'; logoWidth=70; l

纯CSS让radio实现点击显示隐藏效果

—————————————————————————————————————————————————————————————————— ———————————————————————————————————————————————————————————————————— ———————————————————————————————————————————————————————————————————— html <style> #faq input[type='radio']{ displ