11 Star 37 Fork 20

Baryy / You-need-to-know-css

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
scrollbar.md 1.97 KB
一键复制 编辑 原始数据 按行查看 历史
LHammer 提交于 2018-03-19 15:59 . :sparkles:feat: add scrollbar

自定义滚动条

?> 背景知识::point_right: box-shadow, ::-webkit-scrollbar

<script v-pre type="text/x-template" id="scrollbar"> <style> main{ width: 100%; padding: 39px 0; display: flex; align-items: center; justify-content: center; } .scrollbar-main { width:60%; height: 299px; overflow: auto; } .scrollbar-main .row { display: inline-block; padding: 12px; background: rgba(180,160,120,.1); text-align: center; white-space: nowrap; } .scrollbar-main::-webkit-scrollbar { width: 8px; background: white; } .scrollbar-main::-webkit-scrollbar-corner, /* 滚动条角落 */ .scrollbar-main::-webkit-scrollbar-thumb, .scrollbar-main::-webkit-scrollbar-track { border-radius: 5px; } .scrollbar-main::-webkit-scrollbar-corner, .scrollbar-main::-webkit-scrollbar-track { /* 滚动条轨道 */ background-color: rgba(180,160,120,.1); box-shadow: inset 0 0 1px rgba(180,160,120,.5); } .scrollbar-main::-webkit-scrollbar-thumb { /* 滚动条手柄 */ background-color: rgb(180,160,120); } </style>
{{ row }}
<script> module.exports = { computed: { rows: function () { return Array.from({length: 56}).map((v, i) => Array(99).fill(i + 11).join(' ')); } } } </script> </script>

!> 兼容性很差,并且很多样式不可控,建议在生产环境中采用类似 perfect-scrollbar 的方案。

浏览器支持

<iframe src="https://caniuse.bitsofco.de/embed/index.html?feat=css-scrollbar&periods=future_1,current,past_1,past_2,past_3&accessible-colours=false" frameborder="0" width="100%" height="436px"></iframe>
CSS
1
https://gitee.com/lhammer/You-need-to-know-css.git
git@gitee.com:lhammer/You-need-to-know-css.git
lhammer
You-need-to-know-css
You-need-to-know-css
master

搜索帮助