CSS customized scroll bar in div

后端 未结 19 1372
夕颜
夕颜 2020-11-21 11:05

How can I customize a scroll bar via CSS (Cascading Style Sheets) for one div and not the whole page?

19条回答
  •  伪装坚强ぢ
    2020-11-21 11:54

    Suppose you have the div as

    ...

    Apply CSS Styles as

    //custom scroll style definitions
    .custom_scroll
    {
      overflow-y: scroll;
    }
    
    //custom_scroll scrollbar styling
    .custom_scroll::-webkit-scrollbar-track
    {
        -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
        border-radius: 10px;
        opacity: 0.5;
        //background-color: #F5F5F5;
    }
    
    .custom_scroll::-webkit-scrollbar
    {
        width: 5px;
        opacity: 0.5;
        //background-color: #F5F5F5;
    }
    
    .custom_scroll::-webkit-scrollbar-thumb
    {
        border-radius: 10px;
        opacity: 0.5;
        -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
        //background-color: #555;
    }
    

    Resulting Scroll will appear as

提交回复
热议问题