-webkit-内核滚动条样式覆盖

本文介绍了如何使用CSS覆盖Chrome网上商城中独特的滚动条样式。通过示例代码展示了在WebKit内核浏览器(如IE10、Firefox、Chrome和Safari)中自定义滚动条背景、宽度、阴影和边框的方法,预示此类设计可能在未来被广泛应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天看了下Chrome的网上商城, 感觉他们的滚动条很特别. 特地看了下他们的代码, 发现了他们做滚动条的各种元素的覆盖, 这个也可以用作select的框覆盖, 相信不久的将来, 这种css设计会用于各种浏览器, 本人在开发IE10内核的项目时, IE10已经是支持这类css, firefox, chrome和safari也是支持的. 特地分享该例子:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
	.custom-scroll-bar::-webkit-scrollbar{
		background:-webkit-linear-gradient(left,rgba(202, 202, 202, 0.07) 0%,rgba(229, 229, 229, 0.07) 100%);
		width:10px;
		-webkit-box-shadow:0 0 1px 0 rgba(0,0,0,.15) inset,0 1px 0 0 #fff;
		box-shadow:0 0 1px 0 rgba(0,0,0,.15) inset,0 1px 0 0 #fff;
		background-color:#E5E5E5;
	}
	.custom-scroll-bar::-webkit-scrollbar, .custom-scroll-bar::-webkit-scrollbar-thumb{
		overflow: visible;
		border-radius:4px;
		border:solid 1px #A6A6A6;
	}
	.custom-scroll-bar::-webkit-scrollbar-button{
		background-color:transparent;height:0px;display:block;
	}
	.custom-scroll-bar::-webkit-scrollbar-thumb:hover{
		background-color: #fff;
	}
</style>
</head>
<body>
	<div class="custom-scroll-bar" style="width:100px;height:100px;overflow: auto;">
		<div style="width:80px;height:200px;">
			dsadasd
			dsadasd
			dsadasd
			dsadasd
			dsadasd
			dsadasd
			dsadasd
			dsadasd
			dsadasd
			dsadasd
			dsadasd
			dsadasd
		</div>
	</div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值