利用jQuery实现鼠标移动全屏图片切换代码



15 57 20



特效描述:利用jQuery实现 鼠标移动 全屏图片 切换代码,利用jQuery实现鼠标移动全屏图片切换代码

代码结构

1. 引入CSS

<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" href="css/style.css">

2. 引入JS

<script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>

3. HTML代码

<div id="wrap">
  <a href="#" class="hb">
	<div class="c">
	  <img src="images/1.jpg" alt="">
	  <div class="txt">
		<h1>Title here</h1>
		<p>Some longer text here thats wide enough to span on several lines.</p>
	  </div>
	</div>
  </a>
  <div class="fullBg">
	<img src="images/1.jpg" alt="">
  </div>
  <a href="#" class="hb">
	<div class="c">
	  <img src="images/2.jpg" alt="">
	  <div class="txt">
		<h1>Title here</h1>
		<p>Some longer text here thats wide enough to span on several lines.</p>
	  </div>
	</div>
  </a>
  <div class="fullBg">
	<img src="images/2.jpg" alt="">
  </div>
  <a href="#" class="hb">
	<div class="c">
	  <img src="images/3.jpg" alt="">
	  <div class="txt">
		<h1>Title here</h1>
		<p>Some longer text here thats wide enough to span on several lines.</p>
	  </div>
	</div>
  </a>
  <div class="fullBg">
	<img src="images/3.jpg" alt="">
  </div>
  <a href="#" class="hb">
	<div class="c">
	  <img src="images/4.jpg" alt="">
	  <div class="txt">
		<h1>Title here</h1>
		<p>Some longer text here thats wide enough to span on several lines.</p>
	  </div>
	</div>
  </a>
  <div class="fullBg">
	<img src="images/4.jpg" alt="">
  </div>
</div>
<script type="text/javascript">
	$(document).ready(function(){
	  var docWidth = $('body').width(),
		  $wrap = $('#wrap'),
		  $images = $('#wrap .hb'),
		  slidesWidth = $wrap.width();
	  $(window).on('resize', function(){
		docWidth = $('body').width();
		slidesWidth = $wrap.width();
	  })
	  $(document).mousemove(function(e) {
		var mouseX = e.pageX,
			offset = mouseX / docWidth * slidesWidth - mouseX / 2;
		$images.css({
		  '-webkit-transform': 'translate3d(' + -offset + 'px,0,0)',
				  'transform': 'translate3d(' + -offset + 'px,0,0)'
		});
	  });
	})
</script>
<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
</div>



用户评论
大牛,别默默的看了,快登录帮我点评一下吧!:)      登录 | 注册


热门标签: 滑动 滑块 滑动门 触屏滑动 滑动插件 滑块插件 图片滑动 图片滑块

×
×

注册

官方QQ群

扫描上面二维码加微信群

官方QQ群

jQuery/js讨论群
群号:642649996
Css3+Html5讨论群
群号:322131262

加群请备注:从官网了解到