Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/vue-scroll-div/lib/vue-scroll-div.umd.min.js"></script>
<div id="app">
<!--   默认情况 -->
<!--   设置容器的宽高,请直接传值到props属性的`width`和`height`,以及你要设置`padding`。 -->
  <h2>默认情况</h2>
  <div>不做滚动条显示模式设定的默认情况下,会根据您所在浏览器的特性而选择不同的方案。(可用不同浏览器体验下)
    <ul>
      <li>macos 原生滚动条</li>
      <li>webkit内核使用css来美化原生滚动条</li>
      <li>其他浏览器采用HTML元素模拟滚动条</li>
    </ul>
    </div>
  <scroll-div
       width="400px"
       height="100px"
       padding="5px"
       view-class="yourclassname">
  Lorem ipsum dolor, sit amet consectetur adipisicing elit. Officiis quas nobis praesentium nisi deserunt, fuga libero, error quia vero nulla corporis odio fugit atque et accusamus numquam. Tempora, qui numquam!Lorem ipsum dolor, sit amet consectetur adipisicing elit. Officiis quas nobis praesentium nisi deserunt, fuga libero, error quia vero nulla corporis odio fugit atque et accusamus numquam. Tempora, qui numquam!
  </scroll-div>
  
  <h2>仿MacOS效果</h2>
  <p>这里设置`useNative="false"`,关闭智能选择,固定采用仿MacOS的效果,即window系统下的所有浏览器都会采用自定义滚动条模拟</p>
  <scroll-div
       width="400px"
       height="100px"
       :use-native="false">
  Lorem ipsum dolor, sit amet consectetur adipisicing elit. Officiis quas nobis praesentium nisi deserunt, fuga libero, error quia vero nulla corporis odio fugit atque et accusamus numquam. Tempora, qui numquam!Lorem ipsum dolor, sit amet consectetur adipisicing elit. Officiis quas nobis praesentium nisi deserunt, fuga libero, error quia vero nulla corporis odio fugit atque et accusamus numquam. Tempora, qui numquam!
  </scroll-div>
  
 <h2>常驻滚动条模式</h2>
  <p>Windows上的火狐IE等这些非webkit内核的浏览器上,会采用HTML元素模仿滚动条,默认是仿MacOS效果的滚动条,即只有滚动了才会出现。</p>
  <p>如果你不想这样,可以开启常驻滚动条模式,只需要设置`awaysShowScroll="true"`</p>
  <p>本示例最好在火狐或IE上体验</p>
  <scroll-div
       width="400px"
       height="100px"
       :aways-show-scroll="false">
  Lorem ipsum dolor, sit amet consectetur adipisicing elit. Officiis quas nobis praesentium nisi deserunt, fuga libero, error quia vero nulla corporis odio fugit atque et accusamus numquam. Tempora, qui numquam!Lorem ipsum dolor, sit amet consectetur adipisicing elit. Officiis quas nobis praesentium nisi deserunt, fuga libero, error quia vero nulla corporis odio fugit atque et accusamus numquam. Tempora, qui numquam!
  </scroll-div>
  
  <h2>自定义滚动条样式</h2>
  <p>组件本身已经自定义了相对大众美观一点的滚动条了,当然,你仍然有更好的自定义能力,可以通过`barStyle, size, offset`等参数进一步打造属于你的滚动条效果。</p>
  <p>当然,这是针对用HTML元素模拟滚动条效果的情况下,才能生效的</p>
  <scroll-div
       width="400px"
       height="100px"
       :use-native="false"
       :bar-style="{backgroundColor: 'pink', borderRadius: '6px'}">
  Lorem ipsum dolor, sit amet consectetur adipisicing elit. Officiis quas nobis praesentium nisi deserunt, fuga libero, error quia vero nulla corporis odio fugit atque et accusamus numquam. Tempora, qui numquam!Lorem ipsum dolor, sit amet consectetur adipisicing elit. Officiis quas nobis praesentium nisi deserunt, fuga libero, error quia vero nulla corporis odio fugit atque et accusamus numquam. Tempora, qui numquam!
  </scroll-div>
  
 <hr/>
  
  <scroll-div
       width="400px"
       height="100px"
       :use-native="false"
       :bar-style="{backgroundColor: 'rgba(255, 192, 203, .8)', borderRadius: '6px'}"
       size="10px"
       offset="6px"
       :aways-show-scroll="true">
  Lorem ipsum dolor, sit amet consectetur adipisicing elit. Officiis quas nobis praesentium nisi deserunt, fuga libero, error quia vero nulla corporis odio fugit atque et accusamus numquam. Tempora, qui numquam!Lorem ipsum dolor, sit amet consectetur adipisicing elit. Officiis quas nobis praesentium nisi deserunt, fuga libero, error quia vero nulla corporis odio fugit atque et accusamus numquam. Tempora, qui numquam!
  </scroll-div>
</div>
              
            
!

CSS

              
                .scroll-div {
  margin-top: 24px;
}

p {
  color: #409eff;
}
              
            
!

JS

              
                var Main = {
  }
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
              
            
!
999px

Console