css3 - 关于滚动条的CSS如何设置问题
巴扎黑
巴扎黑 2017-04-17 11:19:22
[CSS3讨论组]
<p id='p3' style='width:200px;height:200px;overflow:auto;'>
        This is some text. This is some text. This is some text. This is some text.This is some text. This is some text. This is some text. This is some text.This is some text. This is some text. This is some text. This is some text.This is some text. This is some text. This is some text. This is some text.This is some text. This is some text. This is some text. This is some text.This is some text. This is some text. This is some text. This is some text.This is some text. This is some text. This is some text. This is some text.This is some text. This is some text. This is some text. This is some text.
    </p>

就像上面代码 p里面有一段文字,我设置了overflow:auto;也就是超出部分显示滚动条,那么我如何修改这个滚动条的样式呢?

巴扎黑
巴扎黑

全部回复(4)
ringa_lee

一个针对Webkit内核浏览器的滚动条美化的例子,不知道是不是你想要的

/* 滚动条部分 */
::-webkit-scrollbar {
    width:15px;
}

/* 轨道 */
::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); 
    -webkit-border-radius: 15px;
    border-radius: 15px;
}

/* 手柄 */
::-webkit-scrollbar-thumb {
    -webkit-border-radius: 15px;
    border-radius: 15px;
    background:rgba(200,200,200,0.7); 
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); 
}
/* 手柄激活态 */
::-webkit-scrollbar-thumb:window-inactive {
    background: rgba(200,200,200,0.4); 
}
迷茫

那就定义浏览器滚动条样式即可,两者是一致的,如果需要不一样,那就需要模拟滚动条

PHP中文网

推荐你参考这篇文章:http://www.qianduan.net/css-custom-scroll-bar-style/
作者是微信团队的神飞,写的文章一直很不错!

伊谢尔伦

话说滚动更改滚动条样式。为什么pc端可以正常显示。手机端就不行了呢

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号