javascript - 隐藏水平滚动条但使数据水平滚动

标签 javascript html css angularjs less

我想制作图像滚动器,其中图像可以水平滚动,但不希望水平滚动条在滚动时可见。 下面是我的代码笔的链接..

http://codepen.io/rajMrPerfect/pen/PWewRM?editors=0100

<div class="scroll">
   <img src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" />
  </div>

.scroll {
    height: 180px;
    margin: auto;
    overflow-x: auto;
    overflow-y:hidden;
    white-space: nowrap;
    box-shadow: 0 0 10px #000;  
    img {
        margin: 20px 10px 0 10px;
    }
}

最佳答案

如果你想要一个不可见的滚动条,你将需要一些 JavaScript 代码来处理滚动。

我会使用:https://github.com/asvd/dragscroll

然后:

.scroll {
  height: 180px;
  margin: auto;
  overflow: hidden;
  white-space: nowrap;
  box-shadow: 0 0 10px #000; 
}

img {
  margin: 20px 10px 0 10px;
}
<script src="http://asvd.github.io/dragscroll/dragscroll.js"></script>
<div class="scroll  horizontal dragscroll">
   <img src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" /><img      src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" /><img     src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" /><img src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" /><img  src="http://placehold.it/100x100" />
   <img src="http://placehold.it/100x100" />
  </div>

关于javascript - 隐藏水平滚动条但使数据水平滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42117299/

相关文章:

css - Rails 表单内联

javascript - 如何用视频填充屏幕?

javascript - 使用 ng-repeat 时避免表中的列出现重复索引

javascript - 显示选项文字,而不是值

使用 drawImage 创建后的 JavaScript 保存图像

html - 不要在指定的 div 中应用 CSS - CSS 的法拉第案例

javascript - Backbone.js 设置导致集合中的模型再次成为 "initialize"

javascript - 我无法获取 HTML 页面上元素的值

javascript - CORS 阻止 LinkedIn 共享 API

javascript - 什么是 HTMLDocument 的 Proptype