亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 編程 > JavaScript > 正文

頁面圖片浮動左右滑動效果的簡單實現案例

2019-11-20 21:08:44
字體:
來源:轉載
供稿:網友


核心代碼:

1.css:16sucai.css

復制代碼 代碼如下:

html,body {
 height: 100%;
 margin: 0px;
 padding: 0px;
}
a {outline: none;}
img{ border:0;}
a img {vertical-align: top;}
a img.last {margin-right: 0; }
.box {
 width: 850px;
 height: auto;
 overflow: hidden;
 background: #666;
 margin-top: 10px;
 margin-right: auto;
 margin-bottom: 10px;
 margin-left: auto;
 padding-top: 10px;
 padding-right: 0;
 padding-bottom: 0;
 padding-left: 10px;
}

.box ul {
 margin: 0px;
 padding: 0px;
 float: left;
 list-style-type: none;
}

.box li {
 width: 150px;
 height: 100px;
 float: left;
 cursor: pointer;
 display: inline;
 margin: 0 10px 10px 0;
 border: 5px solid #333;
}

#bg {
 width: 100%;
 height: 898px;
 position: absolute;
 left: 0px;
 top: 0px;
 background: #000;
 filter: alpha(opacity : 50);
 opacity: 0.5;
 display: none;
}

#bg1 {
 width: 100%;
 height: 100%;
 position: absolute;
 left: 0px;
 top: 0px;
 background: #000;
 filter: alpha(opacity : 50);
 opacity: 0.5;
 display: none;
}
#bottom {
 width: 215px;
 height: 50px;
 position: absolute;
 left: 50%;
 bottom: 0px;
 margin: 0 0 0 -107px;
 border: 1px solid #232323;
 background: #444;
 padding: 1px;
 z-index: 1;
 display: none;
}

#bottom ul {
 width: 100%;
 height: 100%;
 margin: 0px;
 padding: 0px;
 list-style-type: none;
 background: #000;
}

#bottom li {
 background: url(../images/ico.jpg) no-repeat;
 float: left;
 display: inline;
 margin: 8px 0 0 18px;
 cursor: pointer;
}

#bottom li.prev {
 width: 30px;
 height: 33px;
 background-position: 0 0;
}

#bottom li.next {
 width: 30px;
 height: 33px;
 background-position: -35px 0;
}

#bottom li.img {
 width: 30px;
 height: 33px;
 background-position: -106px 0;
}

#bottom li.close {
 width: 31px;
 height: 33px;
 background-position: -70px 0;
}

#frame {
 background: #fff;
 padding: 3px;
 position: absolute;
 z-index: 2;
 display: none;
 filter: alpha(opacity : 0);
 opacity: 0;
 text-align: center;
}

#bottom1 {
 width: 215px;
 height: 50px;
 position: absolute;
 left: 50%;
 bottom: 0px;
 margin: 0 0 0 -107px;
 border: 1px solid #232323;
 background: #444;
 padding: 1px;
 z-index: 1;
 display: none;
}

#bottom1 ul {
 width: 100%;
 height: 100%;
 margin: 0px;
 padding: 0px;
 list-style-type: none;
 background: #000;
}

#bottom1 li {
 background: url(../../images/ico.jpg) no-repeat;
 float: left;
 display: inline;
 margin: 8px 0 0 18px;
 cursor: pointer;
}

#bottom1 li.prev {
 width: 30px;
 height: 33px;
 background-position: 0 0;
}

#bottom1 li.next {
 width: 30px;
 height: 33px;
 background-position: -35px 0;
}

#bottom1 li.img {
 width: 30px;
 height: 33px;
 background-position: -106px 0;
}

#bottom1 li.close {
 width: 31px;
 height: 33px;
 background-position: -70px 0;
}

#frame1 {
 background: #fff;
 padding: 3px;
 position: absolute;
 z-index: 2;
 display: none;
 filter: alpha(opacity : 0);
 opacity: 0;
 text-align: center;
}
/
html,body {
 height: 100%;
 margin: 0px;
 font-size: 12px;
}

.mydiv {
 background-color: #FFCC66;
 background:url(../images/loginbg.png) no-repeat;
 border: 0px solid #f00;
 overflow-y:auto;
 overflow-x:auto;
 text-align: center;
 line-height: 40px;
 font-size: 12px;
 font-weight: bold;
 z-index: 999;
 width: 434px;
 height: 238px;
 left: 50%;
 top: 50%;
 margin-left: -200px !important; /*FF IE7 該值為本身寬的一半 */
 margin-top: -80px !important; /*FF IE7 該值為本身高的一半*/
 margin-top: 0px;
 position: fixed !important; /* FF IE7*/
 position: absolute; /*IE6*/
 _top: expression(eval(document . compatMode &&
             document . compatMode == 'CSS1Compat') ?
             documentElement . scrollTop +   ( document .
  documentElement . clientHeight-this . offsetHeight )/ 2 : /*IE6*/
             document . body . scrollTop +   ( document . body .
  clientHeight -   this . clientHeight )/ 2 ); /*IE5 IE5.5*/
}
.mydiv1 {
 background-color: #FFCC66;
 border: 0px solid #f00;
 text-align: center;
 line-height: 40px;
 font-size: 12px;
 font-weight: bold;
 overflow-y:auto;
 overflow-x:auto;
 z-index: 999;
 width: 434px;
 height: 238px;
 left: 50%;
 top: 50%;
 margin-left: -200px !important; /*FF IE7 該值為本身寬的一半 */
 margin-top: -80px !important; /*FF IE7 該值為本身高的一半*/
 margin-top: 0px;
 position: fixed !important; /* FF IE7*/
 position: absolute; /*IE6*/
 _top: expression(eval(document . compatMode &&
             document . compatMode == 'CSS1Compat') ?
             documentElement . scrollTop +   ( document .
  documentElement . clientHeight-this . offsetHeight )/ 2 : /*IE6*/
             document . body . scrollTop +   ( document . body .
  clientHeight -   this . clientHeight )/ 2 ); /*IE5 IE5.5*/
}
.bg,.popIframe {
 background-color: #666;
 display: none;
 width: 100%;
 height: 100%;
 left: 0;
 top: 0; /*FF IE7*/
 filter: alpha(opacity = 50); /*IE*/
 opacity: 0.5; /*FF*/
 z-index: 1;
 position: fixed !important; /*FF IE7*/
 position: absolute; /*IE6*/
 _top: expression(eval(document . compatMode &&
             document . compatMode == 'CSS1Compat') ?
             documentElement . scrollTop +   ( document .
  documentElement . clientHeight-this . offsetHeight )/ 2 : /*IE6*/
             document . body . scrollTop +   ( document . body .
  clientHeight -   this . clientHeight )/ 2 );
}

.popIframe {
 filter: alpha(opacity = 0); /*IE*/
 opacity: 0; /*FF*/
}


2.js事件:
復制代碼 代碼如下:

  <link rel="stylesheet" type="text/css" href="<%=path%>/css/16sucai.css" />
   <script type="text/javascript">
   function aa(id){
    var ID = id.substring(1,2);
    var obj2 = document.getElementById(ID);
    showPigDyt(obj2);
   }
   function showInfo(id)
  {
   document.getElementById(id).style.display = "block";
  }
  function hiddenInfo(id)
  {
   document.getElementById(id).style.display = "none";
  }
   </script>
  <script language="javascript">
   //首頁點擊查看景點熱門照片
  function showPigDyt(obj2) {
   var srcPath = obj2.name;
   var ID= obj2.id;
   var oBox = document.getElementById("con");
   var oBg = document.getElementById("bg");
   var oBot = document.getElementById("bottom");
   var aBli = oBot.getElementsByTagName("li"); 
   var oFrame = document.getElementById("frame");
   //var aLi = oBox.getElementsByTagName("li");
   var aLi=$("li[class='conn']");//獲取所有a標簽的li標簽(集合)
   //var aImg = oBox.getElementsByTagName("img");
   var aImg=$("img[class='conn']");//獲取所有a標簽里的img標簽(集合)
   //alert(aImg);
   var i = iNow = 0;
   for (i = 0; i < aLi.length; i++) {
    aLi[i].index = i;
    aLi[i].onclick = function () {
     with (oFrame.style) {
      display = "block", top = this.offsetTop + "px", left = this.offsetLeft + "px", width = this.offsetWidth + "px", height = this.offsetHeight + "px";
     }
     //alert(srcPath);
     oFrame.innerHTML = "<img id=/"" + ID + "/" onmouseover='upNext(this)' src=/"" + (srcPath) + "/" />";
     var oImg = oFrame.getElementsByTagName("img")[0];
     var iWidth;
     var iHeight;
     if(oImg.width < 600 || oImg.width == 0){
      iWidth = 600;
     }else{
      iWidth = oImg.width;
     }
     if(oImg.width < 425 || oImg.height == 0){
      iHeight = 425;
     }else{
      iHeight = oImg.height;
     }
     var iLeft = parseInt((document.documentElement.clientWidth / 2) - (iWidth / 2));
     var iTop = parseInt((document.documentElement.clientHeight / 2) - (iHeight / 2) - 50);
     with (oImg.style) {
      height = width = "100%";
     }
     startMove(oFrame, {opacity:100, left:iLeft, top:iTop, width:iWidth, height:iHeight});
     oBg.style.display = "block";
     oBot.style.display = "block";
     iNow = this.index + 1;
    };
   }
   document.onmousedown = function () {
    return false;
   };
   aBli[0].onclick = function () {   //箭頭向左事件觸發
    if(ID == 0){
     ID = aLi.length;
    }
    ID--;
    var pathImg = document.getElementById(ID).name;
    oFrame.innerHTML = "<img  id=/"" + ID + "/" onmouseover='upNext(this)' src=/"" + pathImg + "/" width=/"100%/" height=/"100%/" />";
   };
   aBli[1].onclick = function () {
    oFrame.style.cursor = "move";
    oFrame.onmousedown = function (e) {
     var oEvent = e || event;
     var X = oEvent.clientX - oFrame.offsetLeft;
     var Y = oEvent.clientY - oFrame.offsetTop;
     document.onmousemove = function (e) {
      var oEvent = e || event;
      var L = oEvent.clientX - X;
      var T = oEvent.clientY - Y;
      if (L < 0) {
       L = 0;
      } else {
       if (L > document.documentElement.clientWidth - oFrame.offsetWidth) {
        L = document.documentElement.clientWidth - oFrame.offsetWidth;
       }
      }
      if (T < 0) {
       T = 0;
      } else {
       if (T > document.documentElement.clientHeight - oFrame.offsetHeight) {
        T = document.documentElement.clientHeight - oFrame.offsetHeight;
       }
      }
      oFrame.style.left = L + "px";
      oFrame.style.top = T + "px";
      oFrame.style.margin = 0;
      return false;
     };
     document.onmouseup = function () {
      document.onmouseup = null;
      document.onmousemove = null;
     };
     return false;
    };
   };
   aBli[2].onclick = function () {  //箭頭向右事件觸發
    if(ID == (aLi.length-1)){
     ID = -1;
    }
    ID++;
    var pathImg = document.getElementById(ID).name;
    oFrame.innerHTML = "<img id=/"" + ID + "/" onmouseover='upNext(this)' src=/"" + pathImg + "/" width=/"100%/" height=/"100%/" />";
   };
   aBli[3].onclick = function () {  //箭頭關閉事件觸發
    //alert("32" + iNow - 1);
    //alert("32" + aImg[iNow - 1].offsetTop);
    startMove(oFrame, {opacity:0, left:aImg[iNow - 1].offsetLeft, top:aImg[iNow - 1].offsetTop, width:150, height:100}, function () {
     oFrame.style.display = "none";
     oBg.style.display = "none";
     oBot.style.display = "none";
     oFrame.onmousedown = null;
     oFrame.style.cursor = "auto";
    });
   };
  }
  function upNext(bigimg){
   var oBox = document.getElementById("con");
   //var aLi = oBox.getElementsByTagName("li");
   var aLi=$("li[class='conn']");//獲取所有a標簽的li標簽
   var ID = bigimg.id;
   var leftId;
   var rightId;
   if(ID == 0){
    leftId = aLi.length;
    rightId = 1;
   }else if(ID == (aLi.length-1)){
    leftId = (aLi.length-1);
    rightId = 0;
   }else{
    var leftId = ID++;
    var rightId = ID--;
   }
   var leftpath = document.getElementById(--leftId).name;
   var rightpath = document.getElementById(rightId).name;
   var lefturl = "<img id=/"" + leftId + "/" onmouseover='upNext(this)' src=/"" + leftpath + "/" width=/"100%/" height=/"100%/" />";
   var righturl = "<img id=/"" + rightId + "/" onmouseover='upNext(this)' src=/"" + rightpath + "/" width=/"100%/" height=/"100%/" />";
   var width = bigimg.width;
   var height = bigimg.height;
   var imgurl = righturl;
   var oFrame = document.getElementById("frame");
   bigimg.onmousemove=function(){
    if(event.offsetX<width/2){
     bigimg.style.cursor = 'url(images/arr_left.cur),auto';
     imgurl = lefturl;
    }else{
     bigimg.style.cursor = 'url(images/arr_right.cur),auto';
     imgurl = righturl;
    }
   }
   bigimg.onmouseup=function(){
    if(event.offsetX < width/2){
     oFrame.innerHTML = lefturl;
    }else{
     oFrame.innerHTML = righturl;
    }
   }
  }

  function startMove(obj, json, onEnd) {
   clearInterval(obj.timer);
   obj.timer = setInterval(function () {
    doMove(obj, json, onEnd);
   }, 30);
  }
  function getStyle(obj, attr) {
   return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj, false)[attr];
  }
  function doMove(obj, json, onEnd) {
   var attr = "";
   var bStop = true;
   for (attr in json) {
    var iCur = 0;
    if (attr == "opacity") {
     iCur = parseInt(parseFloat(getStyle(obj, attr)) * 100);
    } else {
     iCur = parseInt(getStyle(obj, attr));
    }
    var iSpeed = (json[attr] - iCur) / 5;
    iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
    if (json[attr] != iCur) {
     bStop = false;
    }
    if (attr == "opacity") {
     obj.style.filter = "alpha(opacity:" + (iCur + iSpeed) + ")";
     obj.style.opacity = (iCur + iSpeed) / 100;
    } else {
     obj.style[attr] = iCur + iSpeed + "px";
    }
   }
   if (bStop) {
    clearInterval(obj.timer);
    if (onEnd) {
     onEnd();
    }
   }
  }

</javascript>


3.頁面div布局:
復制代碼 代碼如下:

<div class="pic" id="con">
        <table width="100%" border="0" cellpadding="0" cellspacing="0"
         class="table_01">
         <c:choose>
          <c:when test="${empty image_list}">
           <tr style="height: 20px">
            <td colspan="2">
             暫時沒有圖片信息
            </td>
           </tr>
          </c:when>
          <c:otherwise>
           <%for (int i = 0; i < 3; i++) {%>
            <tr>
           <c:forEach var="image" items="${image_list}"
            begin="<%=i * 5%>" end="<%=(i + 1) * 5 - 1%>" varStatus="strs">

               <td align="left">
                   <ul><li class="conn">
                     <a onclick="aa(this.id)" id="s${strs.index }">
                        <img class="conn" id="${strs.index }" style="height: 116px;width: 116px" src="<%=WholeProperties.IMAGE_IMAGE_URL %>/${image.imagePathSmall}" onclick="showPigDyt(this,${image.imagePathMiddle})" name="<%=WholeProperties.IMAGE_IMAGE_URL %>/${image.imagePathMiddle}"/></a>  
                   </li></ul>
              <ul>
                <li style="line-height:20px">
                  <input type="checkbox" id="upPicID" name="upPicID" value="${image.id }" />
                  <c:choose>
                    <c:when test="${fn:length(image.imageName) > 6}"> 
                       <c:out value="${fn:substring(image.imageName, 0, 6)}..." /> 
                   </c:when>
                    <c:otherwise> 
                       <c:out value="${image.imageName}" /> 
                    </c:otherwise>
                  </c:choose>
                </li>
                <li style="line-height:20px">上傳時間:<c:out value="${fn:substring(image.uploadTime,0,9)}"></c:out></li>
                <li style="line-height:20px">圖片大?。?{image.imageSize }</li>
                       </ul>
                </td>

           </c:forEach>
           </tr>
              <% } %>
          </c:otherwise>
         </c:choose>
        </table>
       </div>
       <div class="shadow_right"></div>
                   <div class="pic_right"></div>
                   <div id="bg"></div>
       <div id="bottom">
         <ul>
           <li class="prev"></li>
              <li class="img"></li>
              <li class="next"></li>
              <li class="close"></li>
          </ul>
       </div>
        <div id="frame"></div>
 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
亚洲欧洲一区二区三区久久| 亚洲视频axxx| 欧美主播福利视频| 久久国产精品久久国产精品| 久久久久久亚洲精品不卡| 亚洲高清不卡av| 色婷婷**av毛片一区| 亚洲一区二区中文字幕| 性色av香蕉一区二区| 正在播放亚洲1区| 久久久久久12| 亚洲成人动漫在线播放| 国产一区二区三区在线看| 在线观看国产精品91| 激情成人在线视频| 成人久久18免费网站图片| 韩国v欧美v日本v亚洲| 国产一区二区三区四区福利| 亚洲欧美激情精品一区二区| 亚洲欧洲中文天堂| 亚洲毛茸茸少妇高潮呻吟| 伊是香蕉大人久久| 青草青草久热精品视频在线观看| 欧美视频中文字幕在线| 亚州国产精品久久久| 欧美最猛性xxxxx(亚洲精品)| 亚洲天堂av综合网| 国产99久久久欧美黑人| 日韩成人中文电影| 国产精品女人网站| 日韩成人性视频| 中日韩美女免费视频网站在线观看| 欧美激情在线狂野欧美精品| 欧美亚洲一区在线| 欧美精品18videosex性欧美| 亚洲va久久久噜噜噜| 日韩在线观看免费全集电视剧网站| 欧美最顶级的aⅴ艳星| 亚洲色图偷窥自拍| 国产美女精品视频| 精品欧美aⅴ在线网站| 91精品久久久久久久久不口人| 色多多国产成人永久免费网站| 亚洲激情在线观看| 国产日产欧美a一级在线| 91精品久久久久久久久久| 国产z一区二区三区| 欧美日韩免费在线观看| 亚洲成年人在线播放| 亚洲影视中文字幕| 亚洲欧美在线x视频| 色先锋久久影院av| 亚洲国产高清福利视频| 国产精品海角社区在线观看| 亚洲人在线观看| 亚洲久久久久久久久久久| 久久伊人免费视频| 久久精品一区中文字幕| 亚洲色图在线观看| 欧美一级成年大片在线观看| 精品爽片免费看久久| 亚洲第一天堂av| 亚洲一区二区日本| 国产午夜精品免费一区二区三区| 亚洲国语精品自产拍在线观看| 欧美大片免费观看在线观看网站推荐| 精品一区二区电影| 91久热免费在线视频| 欧美电影免费看| 精品女同一区二区三区在线播放| 亚洲欧洲日韩国产| 曰本色欧美视频在线| 亚洲男人天堂网站| 日韩在线免费视频观看| 欧美日韩午夜视频在线观看| 国产精品大片wwwwww| 久久精品视频导航| 欧美日韩亚洲国产一区| 色偷偷亚洲男人天堂| 亚洲国产日韩精品在线| 日韩一区二区三区国产| 欧美肥臀大乳一区二区免费视频| 97精品国产91久久久久久| 国产美女久久久| 欧美激情免费在线| 亚洲精品国精品久久99热| 日韩www在线| 亚洲成人网久久久| 久久久国产精品亚洲一区| 久久精品亚洲精品| 91伊人影院在线播放| 亚洲午夜未满十八勿入免费观看全集| 国产国语刺激对白av不卡| 成人黄色免费在线观看| 久久免费成人精品视频| 青青精品视频播放| 日韩欧美aaa| 亚洲影影院av| 亚洲图片欧美午夜| 在线中文字幕日韩| 中文字幕亚洲综合久久| 欧美极品在线播放| 国产男女猛烈无遮挡91| 亚洲第一国产精品| 国产精品亚洲网站| 在线国产精品播放| 91福利视频网| 免费av一区二区| 最近中文字幕mv在线一区二区三区四区| 欧美高清一级大片| 国产精品久久久久aaaa九色| 亚洲欧美日本另类| 欧美综合国产精品久久丁香| 日韩精品在线视频| 亚洲精品日产aⅴ| 国产精品第一第二| 亚洲成人激情在线| 国产97人人超碰caoprom| 精品国产拍在线观看| 中文字幕av一区二区| 国产一区二区免费| 欧美在线精品免播放器视频| 久久亚洲综合国产精品99麻豆精品福利| 一区二区三区精品99久久| 久久精品亚洲94久久精品| 国产一区二区黑人欧美xxxx| 欧美高清视频一区二区| 性欧美在线看片a免费观看| 欧美在线视频一二三| 久久久久久久亚洲精品| 成人国产精品久久久久久亚洲| 国产成人精品a视频一区www| 91香蕉电影院| 欧美日韩国产精品一区| 欧美性猛交xxxxx水多| 热久久这里只有| 国内免费久久久久久久久久久| 亚洲网站在线观看| 国产精品久久久久久网站| 91国内揄拍国内精品对白| 欧美在线免费看| 日韩毛片在线看| 精品久久久久久久久久| 亚洲精品国产综合区久久久久久久| 欧美日韩另类字幕中文| 国产精品久久久久久久天堂| 日韩高清人体午夜| 国产丝袜精品视频| 日韩精品在线免费| 国产精品国产三级国产专播精品人| 中文字幕亚洲综合| 欧美在线观看网站| 综合欧美国产视频二区| 国产91精品黑色丝袜高跟鞋| 国产一区二区三区中文| 亲爱的老师9免费观看全集电视剧| 在线成人中文字幕| 精品久久中文字幕| 久久久久久999| 欧美国产日韩视频| 成人性教育视频在线观看| 久久久这里只有精品视频| 国产精品香蕉在线观看| 伊人久久免费视频|