Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transparent background scrollbar displays on top of content

Tags:

html

css

webkit

I want to achieve this:
enter image description here
What I already achieve:
https://plnkr.co/edit/a3XfJo6Fxtru9V5zpVYR?p=preview
enter image description here

.dropdown-menu { //container
    overflow-y: overlay;
    background-color: transparent;
}
.dropdown-menu::-webkit-scrollbar {
    width:10px;
}
.dropdown-menu::-webkit-scrollbar * {
    background:transparent;
}
.dropdown-menu::-webkit-scrollbar-thumb {
    background:$blue !important;
    border-radius: 6px;
}

Does someone have any ideas how I can do that? How can I make the items stay between their container and the container's scrollbar so they looks like the design? I tried putting z-index in the elements but seems not to work.

like image 482
phuwin Avatar asked Jan 17 '17 12:01

phuwin


1 Answers

Just switch the unit in body tag from % to vw and you will get the over content effect.

body {
  width: 100vw;
  overflow-x: hidden;
}

body::-webkit-scrollbar {
  width: 0.7em;
  background: transparent;
}
body::-webkit-scrollbar-thumb {
  background: #c0392b;
}
like image 110
Losai Avatar answered Sep 22 '22 14:09

Losai