Front-end project modifies default scrollbar style

Posted by logging on Fri, 11 Oct 2019 17:29:31 +0200

Front-end project modifies default scrollbar style

Many projects need to change the default style of scrollbars and do not want to download and introduce plug-ins separately. Therefore, pure css changes the default style of scrollbars. This time, the method is unified and the code is directly loaded.

            &::-webkit-scrollbar {
              // Background of scrollbars
              width: 16px;
              background: #191a37;
              height: 14px;
            }

            &::-webkit-scrollbar-track,
            &::-webkit-scrollbar-thumb {
              border-radius: 999px;
              width: 20px;
              border: 5px solid transparent;
            }

            &::-webkit-scrollbar-track {
              box-shadow: 1px 1px 5px #191a37 inset;
            }

            &::-webkit-scrollbar-thumb {
              //Modification of slider style for scrollbars
              width: 20px;
              min-height: 20px;
              background-clip: content-box;
              box-shadow: 0 0 0 5px #464f70 inset;
            }

            &::-webkit-scrollbar-corner {
              background: #191a37;
            }

This is a complete revision.

The bottom one is very compact. It's worth a try.

            &::-webkit-scrollbar {
              width: 6px;
              height: 6px;
              background: transparent;
            }

            &::-webkit-scrollbar-thumb {
              background: transparent;
              border-radius: 4px;
            }

            &:hover::-webkit-scrollbar-thumb {
              background: hsla(0, 0%, 53%, 0.4);
            }

            &:hover::-webkit-scrollbar-track {
              background: hsla(0, 0%, 53%, 0.1);
            }

The advantage of this is that it's a good experience to move the mouse up to display the modified scrollbars.

(The scrollbar code for hiding an axis at the prompt)

overflow-x:hidden;

Before, I thought it was none. It hasn't changed for half a day.

Topics: Javascript