今天發現 uni-app 項目的滾動條不顯示,查了下原來是設置了
::-webkit-scrollbar {display: none;
}
那么怎么用 css 設置滾動條樣式呢?
定義滾動條整體樣式? ::-webkit-scrollbar
定義滾動條滑塊樣式 ::-webkit-scrollbar-thumb
定義滾動條軌道樣式? ::-webkit-scrollbar-track
好現在推薦 4 個 css 滾動條樣式
.init::-webkit-scrollbar {display: block !important;width: 10px;
}
.init::-webkit-scrollbar-thumb {border-radius: 8px;background-color: #d55959;height: 60px;
}
.init::-webkit-scrollbar-track {border-radius: 8px;background-color: #e7e7e7;border: 1px solid #cacaca;
}
.init::-webkit-scrollbar {display: block !important;background-color: #ac99ba;width: 12px;border-radius: 10px;
}
.init::-webkit-scrollbar-thumb {background-image: -webkit-gradient(linear, left bottom, left top, color-stop(.5, #a520ca), color-stop(1, #2681cc));border-radius: 10px;height: 60px;
}
.init::-webkit-scrollbar-track {border-radius: 10px;box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.3);
}
.init::-webkit-scrollbar {display: block !important;width: 12px;
}
.init::-webkit-scrollbar-thumb {border-radius: 8px;background-color: #95a5a6;border: 1px solid #cacaca;height: 60px;
}
.init::-webkit-scrollbar-track {border-radius: 8px;background-color: #6089b0;
}
.init::-webkit-scrollbar {display: block !important;width: 16px;height: 16px;background-color: #F5F5F5;
}
.init::-webkit-scrollbar-thumb {border-radius: 10px;-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);background-color: #747474;height: 60px;
}
.init::-webkit-scrollbar-track {-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);border-radius: 10px;background-color: #F5F5F5;
}