Apply Border-Radius To Scrollbars with CSS

前端 未结 5 578
闹比i
闹比i 2020-12-15 04:02

To put it simple, this is what i want (obtained on a Webkit Browser using -webkit-scrollbar) :

An

5条回答
  •  有刺的猬
    2020-12-15 04:50

    Put the content that needs to be scrolled in a div with overflow: auto. Around that content div put a div with your rounded corners and overflow: hidden.

    Now you can see the scroll bar but its outer corners are hidden and are not disturbing the rounded corners of the outer div.

    Example:

    // Insert placeholder text
    document.querySelector('.inner').innerHTML = 'Text
    '.repeat(20);
    .outer {
      width: 150pt;
      border: 1px solid red;
      border-radius: 15pt;
      overflow: hidden;
    }
    
    .inner {
      height: 200px;
      overflow-y: auto;
    }

提交回复
热议问题