在Safari中看不到滚动条w / overflow-y:滚动

时间:2015-10-22 18:24:46

标签: html css

如果fixed元素中overflow: autoscroll元素包含body元素overflow: hidden,则在Safari 8.0.x中滚动条不可见,但元素仍然滚动。在Firefox 41.0.x中,滚动条可见。

这是显示行为的fiddle

有没有办法让Safari中的滚动条可见?

*, *:before, *:after {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    min-height: 100%;
    position: relative;
    margin: 0;
    padding: 0;
}

.sidebar {
    position: fixed;
    max-height: 100vh;
    min-height: 100vh;
    background: lightblue;
    width: 200px;
    top: 0;
    right: 0;
    padding: 20px;
    overflow-y: scroll;
}

.content-a {
    background: yellow;
    height: 900px;
}

.main {
    background: grey;
    min-height: 100vh;
    padding: 10px;
}

.content-b {
    height: 200px;
}

body, .main {
    overflow: hidden;
}
<div class="sidebar">
    <div class="content-a">
        content
    </div>
    bottom
</div>
<div class="main">
    <div class="content-b">
        content
    </div>
    bottom
</div>

1 个答案:

答案 0 :(得分:0)

尝试对其进行样式化并强制显示:

::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.4); 
    border-radius: 8px;
    -webkit-border-radius: 8px;
}

::-webkit-scrollbar-thumb {
    -webkit-border-radius: 10px;
    border-radius: 10px;
    background: rgba(100,100,100,0.8); 
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); 
}

正在编辑:

.sidebar::-webkit-scrollbar {
    display: inherit;
}

.sidebar:hover::-webkit-scrollbar {
    width: 10px;
}

.sidebar:hover::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.4); 
    border-radius: 8px;
    -webkit-border-radius: 8px;
}

.sidebar:hover::-webkit-scrollbar-thumb {
    -webkit-border-radius: 10px;
    border-radius: 10px;
    background: rgba(100,100,100,0.8); 
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); 
}