最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

js仿百度有啊通栏展示效果实现代码_javascript技巧

来源:动视网 责编:小采 时间:2020-11-27 21:10:03
文档

js仿百度有啊通栏展示效果实现代码_javascript技巧

js仿百度有啊通栏展示效果实现代码_javascript技巧:效果图如下: 页面代码: 代码如下: 百度有啊通栏展示效果 body,div,dl,dt,dd,ul,li,h3{margin:0;padding:0;} body{color:#333;font:12px/1.5 arial;} li{list-style:none;} a:link,a:visited,a:activ
推荐度:
导读js仿百度有啊通栏展示效果实现代码_javascript技巧:效果图如下: 页面代码: 代码如下: 百度有啊通栏展示效果 body,div,dl,dt,dd,ul,li,h3{margin:0;padding:0;} body{color:#333;font:12px/1.5 arial;} li{list-style:none;} a:link,a:visited,a:activ
 效果图如下:

页面代码:
代码如下:




百度有啊通栏展示效果


function Youa (obj)
{
this.obj = $(obj);
this.container = $("container");
this.control = $("control");
this.items = $$$("item", this.container);
this.iCenter = 2;
this.aSort = [];
this.timer = null;
this.oData = [
{left:0, zIndex:2, opacity:30},
{left:40, zIndex:3, opacity:60},
{left:124, zIndex:4, opacity:100},
{left:208, zIndex:3, opacity:60},
{left:246, zIndex:2, opacity:30},
{left:40, zIndex:0, opacity:0}
];
this.__create__()
};
Youa.prototype.__create__ = function ()
{
var that = this;
var oSpan = null;
var i = 0;
for (i = 0; i < that.items.length; i++)
{
that.items[i].number = i;
that.aSort[i] = that.items[i];
oSpan = document.createElement("span");
oSpan.number = i;
that.control.appendChild(oSpan)
}
for (i = 0; i < 2; i++) this.aSort.unshift(this.aSort.pop());
that.aSpan = $$("span", that.control);
that.control.onmouseover = function (ev)
{
var oEv = ev || event;
var oTarget = oEv.target || oEv.srcElement;
if (oTarget.tagName.toUpperCase() == "SPAN")
{
that.aSort.sort(function (a, b) {return a.number - b.number});
if (oTarget.number < that.iCenter)
{
for (i = 0; i < that.iCenter - oTarget.number; i++) that.aSort.unshift(that.aSort.pop());
that.__set__();
return false
}
else if (oTarget.number > that.iCenter)
{
for (i = 0; i < oTarget.number - that.iCenter; i++) that.aSort.push(that.aSort.shift());
that.__set__();
return false
}
else
{
that.__set__()
}
}
}
this.__set__();
this.__switch__();
this.__autoPlay__()
};
Youa.prototype.__set__ = function ()
{
var i = 0;
for (i = 0; i < this.aSort.length; i++) this.container.appendChild(this.aSort[i]);
for (i = 0; i < this.aSpan.length; i++) this.aSpan[i].className = "";
this.aSpan[this.aSort[this.iCenter].number].className = "active";
for (i = 0; i < this.aSort.length; i++)
{
this.aSort[i].index = i;
if (i < 5)
{
new Animate(this.aSort[i], this.oData[i]);
}
else
{
new Animate(this.aSort[i], this.oData[this.oData.length - 1])
}
}
};
Youa.prototype.__switch__ = function ()
{
var i = 0;
var that = this;
this.container.onclick = function (ev)
{
var oEv = ev || event;
var oTarget = oEv.target || oEv.srcElement;
var index = findItem(oTarget);

if (index < that.iCenter)
{
for (i = 0; i < that.iCenter - index; i++) that.aSort.unshift(that.aSort.pop());
that.__set__();
return false
}
else if (index > that.iCenter)
{
for (i = 0; i < index - that.iCenter; i++) that.aSort.push(that.aSort.shift());
that.__set__();
return false
}
function findItem (element)
{
return element.className == "item" ? element.index : arguments.callee(element.parentNode)
}
};
};
Youa.prototype.__autoPlay__ = function ()
{
var that = this;
that.timer = setInterval(function ()
{
that.aSort[3].click()
}, 3000);
that.obj.onmouseover = function ()
{
clearInterval(that.timer)
};
that.obj.onmouseout = function ()
{
that.timer = setInterval(function ()
{
that.aSort[3].click()
}, 3000)
}
};
function $ (id)
{
return typeof id === "string" ? document.getElementById(id) : id
};
function $$ (tagName, oParent)
{
return (oParent || document).getElementsByTagName(tagName)
};
function $$$ (className, element, tagName)
{
var i = 0;
var aClass = [];
var reClass = new RegExp("(^|//s)" + className + "(//s|$)");
var aElement = $$(tagName || "*", element || document);
for (i = 0; i < aElement.length; i++) reClass.test(aElement[i].className) && aClass.push(aElement[i]);
return aClass
};
function css (element, attr, value)
{
if (arguments.length == 2)
{
if (typeof arguments[1] === "string")
{
return element.currentStyle ? element.currentStyle[attr] : getComputedStyle(element, null)[attr]
}
else
{
for (var property in attr)
{
property == "opacity" ?
(element.style.filter = "alpha(opacity=" + attr[property] + ")", element.style.opacity = attr[property] / 100) :
element.style[property] = attr[property]
}
}
}
else if (arguments.length == 3)
{
switch (attr)
{
case "width":
case "height":
case "top":
case "left":
case "right":
case "bottom":
element.style[attr] = value + "px";
break;
case "opacity" :
element.style.filter = "alpha(opacity=" + value + ")";
element.style.opacity = value / 100;
break;
default :
element.style[attr] = value;
break
}
}
return element
};
function Animate (element, options, fnCallBack)
{
this.obj = $(element);
this.options = options;
this.__onEnd__ = fnCallBack;
this.__startMove__()
};
Animate.prototype.__startMove__ = function ()
{
var that = this;
clearInterval(that.obj.timer);
that.obj.timer = setInterval(function ()
{
that.__doMove__()
}, 30);
};
Animate.prototype.__doMove__ = function ()
{
var complete = true;
var property = null;
for (property in this.options)
{
var iCur = parseFloat(css(this.obj, property));
property == "opacity" && (iCur = parseInt(iCur.toFixed(2) * 100));
var iSpeed = (this.options[property] - iCur) / 5;
iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
this.options[property] == iCur || (complete = false, css(this.obj, property, iSpeed + iCur))
}
complete && (clearInterval(this.obj.timer), this.__onEnd__ && this.__onEnd__.apply(this.obj))
};
window.onload = function ()
{
new Youa("box")
};











必图拳馆
不要把自己困住 你需要释放!
总体评价:
用户印象:过瘾带劲有活力


用户评价




  • thaifight:是一个非常好的一个拳...

  • 快乐小友:散打课的实战机会挺多...

  • 爱情赛车:白天人很少,喜欢安静...












  • 北京「七田阳光」全脑教育培训中心
    点亮孩子智慧人生
    总体评价:
    用户印象:亲切耐心干净


    用户评价




  • Jcenter:如此诚恳的教育机构 ...

  • citaslin:孩子的进步很大

  • 甲鱼爱媛媛:七田阳光很注重品质,...












  • 慕纱莹雪婚纱礼服馆
    物超所值的性价比,尽在慕纱莹雪!
    总体评价:
    用户印象:精致做工好专业


    用户评价




  • 小企鹅快跑:这个周末去取了我定的...

  • 月逢明时:这家婚纱店的婚纱做工...

  • 日历本丢了:上周末去取了婚纱,婚...












  • 北京金三优装饰有限责任公司
    一站式服务让你省时、省力、省钱、省心
    总体评价:
    用户印象:口碑好规模很大讲信誉


    用户评价




  • 紫婧之梦:这家店不错哦!

  • gotometop:装修工都还挺朴实的,...

  • libangcheng1:这家公司还可以,去年...












  • 鸿喜族休闲俱乐部—潘家园店
    专注人类健康,打造财富传奇!
    总体评价:
    用户印象:真好专业手法好


    用户评价




  • 永封de铁盒:环境挺不错,灯光控制...

  • 老冯爱国:不错的地方,是个很有...

  • 白云寺方丈:我不会打台球,但朋友...












  • 北京心拓城拓展培训
    客户第一 执行有力 激情勤奋 简单团结
    总体评价:
    用户印象:专业安全积极


    用户评价




  • janice191:很负责任~

  • 旺达是条鱼:朋友参加过他们的拓展...

  • bjftxiaoniu:吼吼,在这里看到他们...












  • 韩医生专业祛痘连锁机构北京直营店
    我们只祛痘 所以更专业
    总体评价:
    用户印象:效果好细心专业


    用户评价




  • 天涯hehaijiao:这家店很好,顾客很多...

  • 爱神马geili:我治疗了两天感觉的好...

  • 天上的语言:这几天已经看到明显效...












  • 罗曼卡婚纱摄影
    口碑好 性价比高 无额外消费
    总体评价:
    用户印象:口碑好很喜欢完美


    用户评价




  • 明确指出i:拍的很不错,老妈都夸...

  • 爱就一直走吧:他们家服务态度好,衣...

  • 爱过你me:最后照片拍出来后朋友...











  • 文档

    js仿百度有啊通栏展示效果实现代码_javascript技巧

    js仿百度有啊通栏展示效果实现代码_javascript技巧:效果图如下: 页面代码: 代码如下: 百度有啊通栏展示效果 body,div,dl,dt,dd,ul,li,h3{margin:0;padding:0;} body{color:#333;font:12px/1.5 arial;} li{list-style:none;} a:link,a:visited,a:activ
    推荐度:
    • 热门焦点

    最新推荐

    猜你喜欢

    热门推荐

    专题
    Top