4个纯CSS自定义的简单而优雅的滚动条样式
今天发现 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;
}