向可滚动内容添加顶部和底部阴影 jQuery滚动阴影

  • 源码大小:7.36KB
  • 所需积分:1积分
  • 源码编号:19JP-3526
  • 浏览次数:577次
  • 最后更新:2023年06月23日
  • 所属栏目:其他
我要下载
加入收藏
本站默认解压密码:19jp.com 或 19jp_com

简介

scrollingShadows是一个超级简单的jQuery插件,它在可滚动容器的顶部和底部创建细微的阴影,为用户提供视觉反馈,表明他们可以滚动更多的内容。

参见:

  • 向宽HTML表添加滚动阴影–TableScrollShadow

如何使用它:

1.加载scrollingShadows插件的JavaScript和样式表。

  1. <!-- jQuery is required -->
  2. <script src="/path/to/cdn/jquery.slim.min.js"></script>
  3.  
  4. <!-- jQuery scrollingShadows plugin -->
  5. <script src="/path/to/jquery.scrollingShadows.js"></script>
  6. <link rel="stylesheet" href="/path/to/css/jquery.scrollingShadows.css" />

2.在可滚动内容上初始化插件并完成。请注意,父容器必须具有溢流-y设置为汽车or纸卷.

  1. <div id="container" style="width: 400px; height: 400px; overflow: auto">
  2. <div id="longBox">
  3. Long Content here
  4. </div>
  5. </div>
  1. $(function(){
  2. $("#container").scrollingShadows("#longBox");
  3. });

3.覆盖阴影的默认样式。

  1. .scrollShadows-overlay {
  2. background-color: transparent;
  3. background-repeat: no-repeat;
  4. background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
  5. left: 0;
  6. moz-transition: box-shadow 0.05s linear;
  7. ms-transition: box-shadow 0.05s linear;
  8. o-transition: box-shadow 0.05s linear;
  9. pointer-events: none;
  10. position: absolute;
  11. transition: box-shadow 0.05s linear;
  12. webkit-transition: box-shadow 0.05s linear;
  13. z-index: 100;
  14. }
  15.  
  16. .scrollShadows-overlay.top {
  17. box-shadow: inset 0 12px 12px -8px rgba(0,0,0,0),inset 0 -12px 12px -8px rgba(0,0,0,0.5);
  18. moz-box-shadow: inset 0 12px 12px -8px rgba(0,0,0,0),inset 0 -12px 12px -8px rgba(0,0,0,0.5);
  19. webkit-box-shadow: inset 0 12px 12px -8px rgba(0,0,0,0),inset 0 -12px 12px -8px rgba(0,0,0,0.5);
  20. }
  21.  
  22. .scrollShadows-overlay.middle {
  23. box-shadow: inset 0 12px 12px -8px rgba(0,0,0,0.5),inset 0 -12px 12px -8px rgba(0,0,0,0.5);
  24. moz-box-shadow: inset 0 12px 12px -8px rgba(0,0,0,0.5),inset 0 -12px 12px -8px rgba(0,0,0,0.5);
  25. webkit-box-shadow: inset 0 12px 12px -8px rgba(0,0,0,0.5),inset 0 -12px 12px -8px rgba(0,0,0,0.5);
  26. }
  27.  
  28. .scrollShadows-overlay.bottom {
  29. box-shadow: inset 0 12px 12px -8px rgba(0,0,0,0.5),inset 0 -12px 12px -8px rgba(0,0,0,0);
  30. moz-box-shadow: inset 0 12px 12px -8px rgba(0,0,0,0.5),inset 0 -12px 12px -8px rgba(0,0,0,0);
  31. webkit-box-shadow: inset 0 12px 12px -8px rgba(0,0,0,0.5),inset 0 -12px 12px -8px rgba(0,0,0,0);
  32. }

预览截图