我正在使用本网站中看到的平滑 div 滚动条:http ://www.smoothdivscroll.com/ 。
由于某种原因它不起作用,我不知道为什么。我得到的只是一页不滚动的锚定图像。这是我的 HTML:
<div id="makeMeScrollable">
<div class="scrollingHotSpotLeftVisible"></div>
<div class="scrollingHotSpotRightVisible"></div>
<div class="scrollWrapper">
<div class="scrollableArea">
<a href="#"><img src="some-image.png"/></a>
<a href="#"><img src="some-image.png"/></a>
<a href="#"><img src="some-image.png"/></a>
<a href="#"><img src="some-image.png"/></a>
<a href="#"><img src="some-image.png"/></a>
<a href="#"><img src="some-image.png"/></a>
<a href="#"><img src="some-image.png"/></a>
</div>
</div>
这是我的脚本:
<script type="text/javascript" src="jquery.mousewheel.min.js"></script>
<script type="text/javascript" src="jquery.smoothdivscroll-1.2-min.js"></script>
<script src="jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="jquery-ui-1.8.18.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="smoothDivScroll.css" />
<script type="text/javascript">
$(document).ready(function() {
$("#makeMeScrollable").smoothDivScroll({
mousewheelScrolling: true,
manualContinuousScrolling: true,
visibleHotSpotBackgrounds: "always",
autoScrollingMode: "onstart"
});
});
</script>
这是我的CSS:
a img {border: none; }
#makeMeScrollable
{
width:75%;
height:60px;
position: relative;
display: block;
float: left;
padding: 0;
margin: 0;
}
#makeMeScrollable div.scrollableArea img
{
position: relative;
float: left;
margin: 0;
padding: 0;
/* If you don't want the images in the scroller to be selectable, try the following
block of code. It's just a nice feature that prevent the images from
accidentally becoming selected/inverted when the user interacts with the scroller. */
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;
}
我认为这可能是我忽略或没有看到的非常简单的事情,但是已经有一段时间了,我还没有抓住它。
更新
这是我的代码的JsFiddle非常感谢。