最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JS實現(xiàn)可用滑塊滑動的緩動圖代碼

 更新時間:2019年09月01日 08:50:54   作者:鱈魚堡  
這篇文章主要介紹了JS實現(xiàn)可用滑塊滑動的緩動圖代碼,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下

嘗試模仿京東的“發(fā)現(xiàn)好貨”模塊的可用滑塊滑動的緩動圖

JS代碼

function $(id) { return document.getElementById(id); }
//緩動輪播圖
var fhTimer;
var fhNum = 0;
var barNum = 0;
fhTimer = setInterval(marquee, 20);
function marquee() {
  fhNum--;
  barNum = fhNum;
  if(fhNum < -2400) {
    fhNum = 0;
  }
  $("fhc_ul").style.left = fhNum + "px";
  if(fhNum < -2400) {
    barNum = fhNum + 2400;
  }
  $("fhc_dBar").style.left = -(barNum / 2.75) + "px";
}
$("fhcShow").onmouseover = function() {
  $("fhc_d_box").style.display = "block";
  clearInterval(fhTimer);
}
$("fhc_d_box").onmouseover = function() {
  $("fhc_d_box").style.display = "block";
}
$("fhcShow").onmouseout = function() {
  $("fhc_d_box").style.display = "none";
  fhTimer = setInterval(marquee, 20);
}
//鼠標懸浮在標題也在暫停滾動
$("fhTit").onmouseover = function() {
  clearInterval(fhTimer);
}
$("fhTit").onmouseout = function() {
  fhTimer = setInterval(marquee, 20);
}
//滑塊
$("fhc_dBar").onmousedown = function(event) {
  var event = event || window.event;
  var leftValue = event.clientX - this.offsetLeft;
  document.onmousemove = function(event) {
    var evt = event || window.event;
    var locationX = evt.clientX - leftValue;
    if(locationX < 0) {
      locationX = 0;
    }
    else if(locationX > 960 - 99) {
      locationX = 960 - 99;
    }
    $("fhc_dBar").style.left = locationX + "px";
    fhNum = -locationX * 2.75;
    //如果選中了,就取消選中,防止出現(xiàn)bug
    window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
  }
  document.onmouseup = function() {
    document.onmousemove = null;//取消注冊的這個事件
  }
}

HTML代碼

<div class="fxhh_ctt">
  <div class="fh_c_show" id="fhcShow">
    <ul class="fh_c_under" id="fhc_ul">
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <p class="topTit">商品1</p>
        <img src="" alt="">
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <img src="" alt="">
        <p class="botTit">商品2</p>
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <p class="topTit">商品3</p>
        <img src="" alt="">
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <img src="" alt="">
        <p class="botTit">商品4</p>
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <p class="topTit">商品5</p>
        <img src="" alt="">
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <img src="" alt="">
        <p class="botTit">商品6</p>
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <p class="topTit">商品7</p>
        <img src="" alt="">
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <img src="" alt="">
        <p class="botTit">商品8</p>
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <p class="topTit">商品9</p>
        <img src="" alt="">
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <img src="" alt="">
        <p class="botTit">商品10</p>
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <p class="topTit">商品11</p>
        <img src="" alt="">
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <img src="" alt="">
        <p class="botTit">商品12</p>
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <p class="topTit">商品1</p>
        <img src="" alt="">
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <img src="" alt="">
        <p class="botTit">商品2</p>
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <p class="topTit">商品3</p>
        <img src="" alt="">
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <img src="" alt="">
        <p class="botTit">商品4</p>
      </a></li>
      <li><a href=" " rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >
        <p class="topTit">商品5</p>
        <img src="" alt="">
      </a></li>
    </ul>
  </div>
  <!-- 滑塊 -->
  <div class="fhc_box" id="fhc_d_box">
    <div class="fhc_drop" id="fhc_dBar"></div>
  </div>
  <!-- 滑塊end -->
</div>
CSS代碼
.fxhh .fxhh_ctt {
  width: 990px;
  background-color: #fff;
  float: left;
}
.fxhh .fxhh_ctt .fh_c_show .fh_c_under img {
  width: 150px;
  height: 150px;
}
.fxhh .fxhh_ctt .fh_c_show {
  width: 990px;
  height: 260px;
  background-color: #fff;
  overflow: hidden;
  position: relative;
}
.fxhh .fxhh_ctt .fh_c_show .fh_c_under {
  width: 2000%;
  position: absolute;
}
.fxhh .fxhh_ctt .fh_c_show .fh_c_under li {
  float: left;
  text-align: center;
  width: 150px;
  height: 180px;
  margin-top: 40px;
  margin-right: 50px;
}
.fxhh .fxhh_ctt .fh_c_show .fh_c_under li .topTit {
  margin-bottom: 10px;
}
.fxhh .fxhh_ctt .fh_c_show .fh_c_under li .botTit {
  margin-top: 10px;
}
.fxhh .fxhh_ctt .fhc_box {
  display: none;
  width: 960px;
  height: 4px;
  background-color: #f3f3f3;
  margin: 0 auto;
  position: absolute;
  top: 250px;
  left: 210px;
}
.fxhh .fxhh_ctt .fhc_drop {
  width: 99px;
  height: 9px;
  border-radius: 4px;
  background-color: #d8d8d8;
  position: absolute;
  top: -3px;
}

總結

以上所述是小編給大家介紹的JS實現(xiàn)可用滑塊滑動的緩動圖代碼,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復大家的!

相關文章

  • JavaScript 異步調用框架 (Part 1 - 問題 & 場景)

    JavaScript 異步調用框架 (Part 1 - 問題 & 場景)

    在Ajax應用中,調用XMLHttpRequest是很常見的情況。特別是以客戶端為中心的Ajax應用,各種需要從服務器端獲取數(shù)據(jù)的操作都通過XHR異步調用完成。
    2009-08-08
  • JS實現(xiàn)DIV高度自適應窗口示例

    JS實現(xiàn)DIV高度自適應窗口示例

    這篇文章主要介紹了JS實現(xiàn)DIV高度自適應窗口的方法,結合完整實例形式分析了JS通過動態(tài)操作頁面元素屬性實現(xiàn)高度自適應的相關技巧,需要的朋友可以參考下
    2017-02-02
  • js+canvas實現(xiàn)圖片格式webp/png/jpeg在線轉換

    js+canvas實現(xiàn)圖片格式webp/png/jpeg在線轉換

    這篇文章主要介紹了js+canvas實現(xiàn)圖片格式webp/png/jpeg在線轉換,需要的朋友可以參考下
    2020-08-08
  • JS實現(xiàn)可編輯的后臺管理菜單功能【附demo源碼下載】

    JS實現(xiàn)可編輯的后臺管理菜單功能【附demo源碼下載】

    這篇文章主要介紹了JS實現(xiàn)可編輯的后臺管理菜單功能,涉及javascript針對頁面元素的遍歷及動態(tài)修改相關操作技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下
    2016-09-09
  • js實現(xiàn)文本框輸入文字個數(shù)限制代碼

    js實現(xiàn)文本框輸入文字個數(shù)限制代碼

    這篇文章主要介紹了js實現(xiàn)文本框輸入文字個數(shù)限制代碼,文本框輸入的文字個數(shù)并不是無限制的,一般都會限定一個輸入最高上限,如何限制,請看本文
    2015-12-12
  • JS煙花背景效果實現(xiàn)方法

    JS煙花背景效果實現(xiàn)方法

    這篇文章主要介紹了JS煙花背景效果實現(xiàn)方法,實例分析了javascript操作dom元素實現(xiàn)煙花特效的技巧,需要的朋友可以參考下
    2015-03-03
  • 使用JavaScript渲染頁面的方法詳解

    使用JavaScript渲染頁面的方法詳解

    本文主要介紹了使用JavaScript渲染頁面的方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,感興趣的小伙伴下面隨著小編來一起來學習吧
    2023-12-12
  • 利用JS如何獲取form表單數(shù)據(jù)

    利用JS如何獲取form表單數(shù)據(jù)

    這篇文章主要給大家介紹了關于利用JS如何獲取form表單數(shù)據(jù)的相關資料,文中通過示例代碼介紹的非常詳細,對大家學習或者使用JS具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧
    2019-12-12
  • 前端url拼接參數(shù)格式&?用&和??=拼接方法實例

    前端url拼接參數(shù)格式&?用&和??=拼接方法實例

    在一些情況下需要直接往url上拼接請求參數(shù),下面這篇文章主要給大家介紹了關于前端url拼接參數(shù)格式&?用&和??=拼接的相關資料,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下
    2023-02-02
  • 利用10行js代碼實現(xiàn)上下滾動公告效果

    利用10行js代碼實現(xiàn)上下滾動公告效果

    這篇文章主要給大家介紹了關于利用10行js代碼實現(xiàn)滾動公告效果的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起看看吧。
    2017-12-12

最新評論

江都市| 交城县| 连南| 阆中市| 永昌县| 永寿县| 江源县| 贺州市| 定兴县| 屯昌县| 武冈市| 贵南县| 昆山市| 大关县| 突泉县| 安岳县| 错那县| 海城市| 江津市| 方山县| 崇阳县| 黄山市| 灵宝市| 涡阳县| 襄城县| 桂阳县| 林周县| 罗定市| 榕江县| 漳州市| 娱乐| 广昌县| 新晃| 阿拉善右旗| 西城区| 上饶市| 都江堰市| 华蓥市| 华亭县| 淮安市| 娄底市|