使用jquery自定义滑动插件

时间:2016-03-18 09:22:16

标签: javascript jquery html css

我想使用jQuery自定义滑动插件,如下所示: enter image description here

我的代码结构是:

HTML

<div class="benefit-container">
  <div class="benefit-title-container">
    <div class="benefit-title">Why use Citrix Service Providers to Help Solve Your Business Problems?</div>
  </div>
  <div class="benefit-scroll-container">
    <div id="benefit-support" class="benefit-sub-title">Support</div>
    <div id="benefit-access" class="benefit-sub-title">Access</div>
    <div id="benefit-service" class="benefit-sub-title">Service</div>
    <div id="benefit-business-model" class="benefit-sub-title">Business Model</div>
    <div id="benefit-choice" class="benefit-sub-title">Choice</div>
  </div>
</div>

CSS

div.benefit-scroll-container{
    position: relative;
    margin-bottom: 36px;
    overflow-x: visible;
    white-space: nowrap;
    text-align: center;
    border-top: 1px solid #cfd1d3;
    border-bottom: 1px solid #cfd1d3;
    line-height: 44px;
    padding-left: 10px;
    padding-right: 10px;
}

我的想法是:当触摸移动插件时,我将改变好处滚动容器的位置。

当我设置&#34; good-scroll-container&#34;具有以下内容的类并向左滑动。我发现有些部分丢失了,如下图所示。

div.benefit-scroll-container{
        overflow-x: hidden;
    }

enter image description here

如果我设置&#34; good-scroll-container&#34;以下课程。

div.benefit-scroll-container{
            overflow-x: visible;
        }

然后我向左滑动,发现整个页面将被向左滑动,一些插件会丢失边框,如下图所示。

enter image description here

如何解决此问题

1 个答案:

答案 0 :(得分:0)

给div.benefit-scroll-container一个宽度,然后像这样提供scroll属性:

div.benefit-scroll-container {
        width: 1000px; //or 100% as per your use
        overflow-x: scroll;
    }