xml地图|网站地图|网站标签 [设为首页] [加入收藏]

javascript图片滑动效果实现,JS实现的适合做faq或

来源:http://www.ccidsi.com 作者:最新解决方案 人气:197 发布时间:2019-09-04
摘要:本文为我们享用了javascript图片滑动作效果果落到实处格局,具体内容如下,先看一下功用图: 本文实例叙述了JS达成的适合做faq或menu滑动效果。共享给大家供我们参谋,具体如下: 明

本文为我们享用了javascript图片滑动作效果果落到实处格局,具体内容如下,先看一下功用图:

本文实例叙述了JS达成的适合做faq或menu滑动效果。共享给大家供我们参谋,具体如下:

明天看了他人写的图纸滑动,看起来很酷,读源码时,就像是不怎么困难,就模仿着写了三个,达成的功用与原网页一样,可是本人的js代码,逻辑轻便,有待改革。
ps:前两日写了旋转木马,这个包容性不佳,前日写这么些网页的时候,也是依照那些思路,在谷歌(Google)浏览器上运转很好,火狐很多功力不能够落成,由于wrap——panel使用了相对定位,就将translate平移改为了left。更动后,各种浏览器运维的功能不错。

图片 1

<!CTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
body,div,ul,li,p,h1,h2{ margin:0; padding:0; border:0; background:#FAFAFA; font-family:Arial, Helvetica, sans-serif,"宋体"}
body{ text-align:center; font-size:12px}
li{ list-style:none}
.rolinList{ width:402px; height:auto; margin:20px auto 0 auto; text-align:left}
.rolinList li{margin-bottom:1px;border:1px solid #DADADA}
.rolinList li h2{ width:380px; height:40px; background:#fff; font-size:14px; line-height:40px; padding-left:20px; color:#333; cursor:pointer}
.content{ height:150px;width:400px; background:#fff; background:#FAFAFA}
.content p{ margin:12px}
-->
</style>
<script type="text/javascript">
//<![CDATA[
window.onload = function() {
rolinTab("rolin")
}
function rolinTab(obj) {
var list = $(obj).getElementsByTagName("LI");
var state = {show:false,hidden:false,showObj:false};
for (var i=0; i<list.length; i  ) {
var tmp = new rolinItem(list[i],state);
if (i == 0) tmp.pShow();
}
}
function rolinItem(obj,state) {
var speed = 0.0666; 
var range = 1;
var interval;
var tarH;
var tar = this;
var head = getFirstChild(obj);
var content = getNextChild(head);
var isOpen = false;
this.pHidden = function() {
if (isOpen) hidden();
}
this.pShow = show;
var baseH = content.offsetHeight;
content.style.display = "none";
var isOpen = false;
head.onmouseover = function() {
this.style.background = "#EFEFEF";
}
head.onmouseout = mouseout;
head.onclick = function() {
this.style.background = "#EFEFEF";
if (!state.show && !state.hidden) {
if (!isOpen) {
head.onmouseout = null;
show();
} else {
hidden();
}
}
}
function mouseout() {
this.style.background = "#FFF"
}
function show() {
head.style.borderBottom = "1px solid #DADADA";
state.show = true;
if (state.openObj && state.openObj != tar ) {
state.openObj.pHidden();
}
content.style.height = "0px";
content.style.display = "block";
content.style.overflow = "hidden";
state.openObj = tar;
tarH = baseH;
interval = setInterval(move,10);
}
function showS() {
isOpen = true;
state.show = false;
}
function hidden() {
state.hidden = true;
tarH = 0;
interval = setInterval(move,10);
}
function hiddenS() {
head.style.borderBottom = "none";
head.onmouseout = mouseout;
head.onmouseout();
content.style.display = "none";
isOpen = false;
state.hidden = false;
}
function move() {
var dist = (tarH - content.style.height.pxToNum())*speed;
if (Math.abs(dist) < 1) dist = dist > 0 ? 1: -1;
content.style.height = (content.style.height.pxToNum()   dist)   "px";
if (Math.abs(content.style.height.pxToNum() - tarH) <= range ) {
clearInterval(interval);
content.style.height = tarH   "px";
if (tarH != 0) {
showS()
} else {
hiddenS();
}
}
}
}
var $ = function($) {return document.getElementById($)};
String.prototype.pxToNum = function() {return Number(this.replace("px",""))}
function getFirstChild(obj) {
var result = obj.firstChild;
while (!result.tagName) {
result = result.nextSibling;
}
return result;
}
function getNextChild(obj) {
var result = obj.nextSibling;
while (!result.tagName) {
result = result.nextSibling;
}
return result;
}
//]]>
</script>
<ul id="rolin">
  <li>
  <h2>脚本之家 1</h2>
  <div <p>脚本之家--专业IT综合性网站<br /><br /><a target="_blank" href="//www.jb51.net/">//www.jb51.net/</a></p>
  </div>
  </li>
  <li>
  <h2>脚本之家 2</h2>
  <div <p>脚本之家--专业IT综合性网站<br /><br /><a target="_blank" href="//www.jb51.net/">//www.jb51.net/</a></p>
  </div>
  </li>
  <li>
  <h2>脚本之家 3</h2>
  <div <p>脚本之家--专业IT综合性网站<br /><br /><a target="_blank" href="//www.jb51.net/">//www.jb51.net/</a></p>
  </div>
  </li>
  <li>
  <h2>脚本之家 4</h2>
  <div <p>脚本之家--专业IT综合性网站<br /><br /><a target="_blank" href="//www.jb51.net/">//www.jb51.net/</a></p>
  </div>
  </li>
  <li>
  <h2>脚本之家 5</h2>
  <div <p>脚本之家--专业IT综合性网站<br /><br /><a target="_blank" href="//www.jb51.net/">//www.jb51.net/</a></p>
  </div>
  </li>
  <li>
  <h2>脚本之家 6</h2>
  <div <p>脚本之家--专业IT综合性网站<br /><br /><a target="_blank" href="//www.jb51.net/">//www.jb51.net/</a></p>
  </div>
  </li>
</ul>

具体代码如下

鼠标滑过那张图,展现完整的哪张图,移除则复位:

更加多关于JavaScript相关内容感兴趣的读者可查看本站专项论题:《JavaScript切换特效与技能总括》、《JavaScript查找算法本领总计》、《JavaScript动画特效与技能汇总》、《JavaScript错误与调治技能总计》、《JavaScript数据结构与算法技术总结》、《JavaScript遍历算法与本领总计》及《JavaScript数学生运动算用法总括》

html代码(没写注释)

图片 2

梦想本文所述对大家JavaScript程序设计有着支持。

<div class="container"> 
    <h1>Parallax Slider</h1> 
    <div class="wrap"> 
      <div class="bg-img"> 
        <div id="bg_1" class="bg bg-1" style="left: 0px;"></div> 
        <div id="bg_2" class="bg bg-2" style="left: 0px;"></div> 
        <div id="bg_3" class="bg bg-3" style="left: 0px;"></div> 
      </div> 
      <div id="wrap_panel" class="wrap-panel" style="left: 0px;"> 
        <div class="panel panel-1"> 
          <img id="img_1" src="images/1.jpg"> 
        </div> 
        <div class="panel panel-2"> 
          <img src="images/2.jpg"> 
        </div> 
        <div class="panel panel-3"> 
          <img src="images/3.jpg"> 
        </div> 
        <div class="panel panel-4"> 
          <img src="images/4.jpg"> 
        </div> 
        <div class="panel panel-5"> 
          <img src="images/5.jpg"> 
        </div> 
        <div class="panel panel-6"> 
          <img src="images/6.jpg"> 
        </div> 
      </div> 
      <div class="navigation-button"> 


      </div> 
      <div id="show_small" class="show-small"> 
        <ul> 
          <li><img src="images/thumbs/1.jpg"></li> 
          <li><img src="images/thumbs/2.jpg"></li> 
          <li><img src="images/thumbs/3.jpg"></li> 
          <li><img src="images/thumbs/4.jpg"></li> 
          <li><img src="images/thumbs/5.jpg"></li> 
          <li><img src="images/thumbs/6.jpg"></li> 
        </ul> 
      </div> 
    </div> 
  </div> 

本文由68399皇家赌场发布于最新解决方案,转载请注明出处:javascript图片滑动效果实现,JS实现的适合做faq或

关键词: 68399皇家赌场

最火资讯