js实现鼠标可实现左滚动右滚动效果

这篇博客适合已经掌握HTML基础、CSS布局和JS运动基础知识的读者。内容主要讲解如何使用JavaScript和CSS3创建鼠标滚轮触发的页面左右滚动效果,通过实例代码展现布局和交互动画的配置。
摘要由CSDN通过智能技术生成

需要掌握以下要点知识的基础人员:

掌握html基本元素基础知识

掌握css布局基础知识

js运动基础知识

本实例很简单,重在考研大家的功底

样式css

*{
	padding: 0;
	margin: 0;
}
li{
	list-style: none;
}
img{
	border:0;
}
/* 控制 */
.control{
	border-bottom: 1px solid #ccc;
	background-color: #eee;
	text-align: center;
	padding: 20px 0; /* 上下距离20px 左右0 */
}
#showmsg{
	font-size: 25px;
}
.roll{
	width: 880px;
	height: 108px;
	margin: 50px auto;
	position: relative;
}
.roll ul{
	position: absolute;
	top: 0;
	left: 0;
}
.roll li{
	float: left;
	width: 182px;
	height: 108px;
	
}
.roll li a:hover{
	position: relative;
	top: 2px;
}
.roll .wrap{
	width: 728px;
	height: 108px;
	position: relative;
	margin: 0 auto;
	overflow: hidden;
}
/* 左按钮 */
.btn_left{
	display: block;
	width: 68px;
	height: 68px;
	background: url(../images/btn.jpg) no-repeat -70px -69px ;
	position: absolute;/* //绝对定位会脱标 不会占据位置 */
	top: 20px;
	left: 1px;
	z-index: 1;
}
.btn_left:hover{
	background-position: -70px 0;
}
.btn_right{
	width: 68px;
	height: 68px;
	background: url(../images/btn.jpg) no-repeat 1px -69px;
	position: absolute;
	right: 1px;
	top: 20px;
	z-index: 1;
}
.btn_right:hover{
	background-position: 1px 0;
}

js文件配置,实现交互动画效果


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

红豌豆

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值