1. 程式人生 > >前端給div加滾動條樣式修改

前端給div加滾動條樣式修改

<!DOCTYPE html> <html lang="en">       <head>             <meta charset="UTF-8">             <title>滾動條示例</title>             <style type="text/css">                   .nui-scroll {                         margin-left: 100px;                         border: 1px solid #000;                         width: 200px;                         height: 100px;                         overflow: auto;                   }                                      .nui-scroll::-webkit-scrollbar {                         width: 8px;                         height: 8px;                   }                   /*正常情況下滑塊的樣式*/                                      .nui-scroll::-webkit-scrollbar-thumb {                         background-color: rgba(0, 0, 0, .05);                         border-radius: 10px;                         -webkit-box-shadow: inset 1px 1px 0 rgba(0, 0, 0, .1);                   }                   /*滑鼠懸浮在該類指向的控制元件上時滑塊的樣式*/                                      .nui-scroll:hover::-webkit-scrollbar-thumb {                         background-color: rgba(0, 0, 0, .2);                         border-radius: 10px;                         -webkit-box-shadow: inset 1px 1px 0 rgba(0, 0, 0, .1);                   }                   /*滑鼠懸浮在滑塊上時滑塊的樣式*/                                      .nui-scroll::-webkit-scrollbar-thumb:hover {                         background-color: rgba(0, 0, 0, .4);                         -webkit-box-shadow: inset 1px 1px 0 rgba(0, 0, 0, .1);                   }                   /*正常時候的主幹部分*/                                      .nui-scroll::-webkit-scrollbar-track {                         border-radius: 10px;                         -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0);                         background-color: white;                   }                   /*滑鼠懸浮在滾動條上的主幹部分*/                                      .nui-scroll::-webkit-scrollbar-track:hover {                         -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .4);                         background-color: rgba(0, 0, 0, .01);                   }             </style>       </head>       <body>             <div class="nui-scroll">                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <br/> 123                   <!--這裡有好多上面這結構為了節省篇幅就省去了-->             </div>       </body> </html>

本文轉載於:猿2048https://www.mk2048.com/blog/blog.php?id=jkcckj&title=%E5%89%8D%E7%AB%AF%E7%BB%99div%E5%8A%A0%E6%BB%9A%E5%8A%A8%E6%9D%A1%E6%A0%B7%E5%BC%8F%