css改变滚动条的颜色-横向滚动demo效果示例(整理)

<!DOCTYPE HTML>
<html>
<head>
    <title>改变滚动条的颜色</title>
<style>
	.inner{
		width: 265px;
		height: 400px;
		position: absolute;
		top: 33px;
		left: 13px;
		/*cursor: pointer;*/
		overflow:hidden;
	}
	.innerbox{
		overflow-x: hidden;
		overflow-y: auto;
		color: #000;
		font-size: .7rem;
		height: 100%;
	}
	/*核心代码*/
	.innerbox::-webkit-scrollbar {/*滚动条整体样式*/
		width: 4px; /*高宽分别对应横竖滚动条的尺寸*/
		height: 4px;
	}
	.innerbox::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
		border-radius: 5px;
		-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
		background: rgba(0,0,0,0.2);
	}
	.innerbox::-webkit-scrollbar-track {/*滚动条里面轨道*/
		-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
		border-radius: 0;
		background: rgba(0,0,0,0.1);
	}
	/*核心代码*/
</style>
</head>
<body>
<div class="inner">
	<div class="innerbox">
		<p style="height:200px;">111</p>
		<p style="height:600px;">222</p>
		<p>333</p>
	</div>
</div>
</body>
</html>

<div style="width: 375px;height: 100%;">


    <style>
		/*核心代码*/
		.warp::-webkit-scrollbar {/*滚动条整体样式*/
			width: 4px; /*高宽分别对应横竖滚动条的尺寸*/
			height: 4px;
		}
		.warp::-webkit-scrollbar-thumb {/*滚动条里面小方块 0.5是滚筒条透明度*/
			border-radius: 5px;
			-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
			background: rgba(0,0,0,0);
		}
		.warp::-webkit-scrollbar-track {/*滚动条里面轨道*/
			-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
			border-radius: 0;
			background: rgba(0,0,0,0);
		}
		/*核心代码*/
        .warp {
            font-size: 0;
            white-space: nowrap;
            overflow: scroll;
        }
        .item {
            background: red;
            display: inline-block;
            font-size: 14px;
            width: 25%;
            height: 50px;
            text-align: center;
            line-height: 50px;
            color: #fff;
        }
    </style>
    <div class="warp">
    <!-- 横向滚动 -->
        <div class="item">111</div>
        <div class="item">2</div>
        <div class="item">3</div>
        <div class="item">4</div>
        <div class="item">5</div>
        <div class="item">6</div>
        <div class="item">7</div>
        <div class="item">8</div>
        <div class="item">9</div>
        <div class="item">10</div>          
    </div>
</div>

效果图在这里插入图片描述

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

知 秋~

文章里可以看到打赏码哦~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值