简体   繁体   English

div内部和顶部的滚动条

[英]Scrollbar Inside and On Top of the Div

I am wondering if it is possible to have a scrollbar inside and on top of the DIV as oppose to next to it? 我想知道是否有可能在DIV的内部和顶部有一个滚动条,与之相邻? I am developing a chrome extension where I have a DIV that contains information on the far right side of the page. 我正在开发chrome扩展程序,其中有一个DIV,该DIV包含页面最右侧的信息。 When the DIV exceeds the height of the page, a scrollbar appears next to this DIV as oppose to inside and on top of the DIV. 当DIV超过页面的高度时,该DIV旁边将出现一个滚动条,与DIV的内部和顶部相反。 In addition, I am wondering if it is possible to get the scrollbar to fade when the user does not hover over it? 另外,我想知道当用户不将滚动条悬停在滚动条上时是否可以使其淡入淡出?

I have modified the appearance of the scrollbar by using -webkit in the css. 我已经通过在CSS中使用-webkit修改了滚动条的外观。 Here is a snippet of what I have done: 这是我所做的摘要:

#sidebar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

#sidebar::-webkit-scrollbar-track-piece  {
    background-color: #f3f3f3;
    -webkit-border-radius: 0px;
}

#sidebar::-webkit-scrollbar-thumb:vertical {
    height: 50px;
    background-color: #ccc;
    -webkit-border-radius: 0px;
}

As far as having the "inner" scrollbar, you can make the illusion of this by wrapping the DIV with another DIV of equal height and with the desired permanent width. 只要具有“内部”滚动条,就可以通过用另一个等高并具有所需永久宽度的DIV包装DIV来产生这种错觉。 Then set the inner DIV to 100% width, and it will adjust as the scrollbar appears. 然后将内部DIV设置为100%宽度,它将随着滚动条的出现进行调整。 As far as the fade, I don't believe the scrollbar is part of the DOM, so Javascript is out, but you may be able to use the animate property in CSS http://fvsch.com/code/transition-fade/test1.html 至于淡入淡出,我不相信滚动条是DOM的一部分,因此Javascript已经淘汰,但是您可以使用CSS http://fvsch.com/code/transition-fade/中的animate属性test1.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM