4个纯CSS自定义的简单而优雅的滚动条样式

今天发现 uni-app 项目的滚动条不显示,查了下原来是设置了

复制代码
::-webkit-scrollbar {
    display: none;
}

那么怎么用 css 设置滚动条样式呢?

定义滚动条整体样式‌ ::-webkit-scrollbar

定义滚动条滑块样式 ::-webkit-scrollbar-thumb

定义滚动条轨道样式‌ ::-webkit-scrollbar-track

好现在推荐 4 个 css 滚动条样式

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;
}
css 复制代码
.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);
}
css 复制代码
.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;
}
css 复制代码
.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;
}
相关推荐
啊哈一半醒12 分钟前
React 核心知识点系统总结:从基础语法到高级 API,一篇文章梳理完整学习路线
javascript·学习·react.js
2401_8784545330 分钟前
HTML和CSS的复习2
前端·css·html
We་ct37 分钟前
吃透现代CSS全技术体系
前端·css·css3·sass·postcss·预处理器
ZC跨境爬虫38 分钟前
跟着 MDN 学 HTML day_11:(语义化容器全站重构+独立CSS拆分+字体合规引入)
前端·css·ui·重构·html·edge浏览器
何何____39 分钟前
flex布局介绍
css
ZC跨境爬虫41 分钟前
跟着 MDN 学 HTML day_10:(超链接核心语法+路径规则)
前端·css·笔记·ui·html·edge浏览器
GISer_Jing43 分钟前
AI原生前端工程化进阶实践:从流式交互架构到端云协同全链路落地
前端·人工智能·后端·学习
被考核重击1 小时前
Vue响应式原理(下)
前端·javascript·vue.js
ZC跨境爬虫9 小时前
跟着 MDN 学 HTML day_9:(信件语义标记)
前端·css·笔记·ui·html
前端老石人9 小时前
HTML 字符引用完全指南
开发语言·前端·html