如何向下滚动并向上滚动滚动框外的按钮?

时间:2016-09-03 08:07:38

标签: javascript jquery css html5 google-chrome

游戏设计师让我使用自定义向上和向下按钮以及自定义滚动条创建滚动条(不是通过谷歌浏览器在Windows上从浏览器本机提供的滚动条)

enter image description here

我尝试了如下,但我如何删除div内的原生卷轴?在div之外使用我自己的外观和感觉垂直滚动条,它可以与我现有的div交互?



.FixedHeightContainer {
  height: 250px;
  width:250px; 
  padding:3px; 
  background:#f00;
}
.Content {
  height:224px;
  overflow:auto;
  background:#fff;
}

<span>UP</span>
<br/>
<div class="FixedHeightContainer">
  <h2>Title</h2>
  <div class="Content">
    Game UI sucks<Br/>
    Game UI i hate it, nightmare for programmers<Br/>
    Game UI is hard<Br/>
    Game UI<Br/>
    Game UI<Br/>
    Game UI<Br/>
    Game UI<Br/>
    Game UI<Br/>
    Game UI<Br/>
    Game UI<Br/>
    Game UI<Br/>
    Game UI<Br/>
    Game UI<Br/>
    Game UI<Br/>
    Game UI<Br/>
    Game UI<Br/>
  </div>
</div>

<Br/>
<span>DOWN</span>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

请参阅以下链接。对于与自定义滚动条相关的所有查询,它是一站式解决方案。

css-tricks scrollbar

编辑: View Demo

/* For the "inset" look only */
html {
    overflow: auto;
}

body {
    position: absolute;
    top: 20px;
    left: 20px;
    bottom: 20px;
    right: 20px;
    padding: 30px; 

    overflow-y: scroll;
    overflow-x: hidden;
}

/* FAT or SLIM? */
::-webkit-scrollbar {
    width: 12px;
}

/* Slider bar */
::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); 
    -webkit-border-radius: 10px;
    border-radius: 10px;
}

/* Button inside the slider  */
::-webkit-scrollbar-thumb {
    -webkit-border-radius: 10px;
    border-radius: 10px;
    background: rgba(255,0,0,0.8); 
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); 
}

::-webkit-scrollbar-thumb:window-inactive {
    background: rgba(255,0,0,0.4); 
}