前端JS——滑动滑块验证登录(源码及效果)

1.html代码

<div class="box">
			<!--滑块-->
			<a href="#"><div class="btn">>></div></a>
			<!--文字-->
			<p class="text">拖动滑块验证</p>
			<!--背景-->
			<div class="bg"></div>			
</div>

2.css样式

最大的盒子相对定位,其他内部内容绝对定位
需要根据层级设置z-index保证滑动的正常使用

.box{
	position: relative;
	width: 300px;
	height: 34px;
	background: #e8e8e8;
	border-radius: 4px;
	left: 20px;
}
.btn{
	position: absolute;
	top: 0;
	width: 40px;
	height:32px;
	text-align: center;
	line-height: 32px;
	border-radius: 4px;
	z-index: 3;
	background-color: #fff;
	border: 1px solid #ccc;
	color: black;
}
.text{
	position: absolute;
	width: 100%;
	margin: 0;
	text-align: center;
	line-height: 34px;
	display: block;
	z-index: 2;
	/*-webkit-margin-before: 1em;
	-webkit-margin-after: 1em;*/
}
.bg{
	position: absolute;
	height: 100%;
	background-color: yellowg
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值