基于jquery实现鼠标滚动显示导航菜单代码



34 135 46



特效描述:基于jquery实现 鼠标滚动 显示导航菜单,基于jquery实现鼠标滚动显示导航菜单代码

代码结构

1. 引入CSS

<link rel="stylesheet" media="all" type="text/css" href="css/jquery-rebox.css" />

2. 引入JS

<script src="js/jquery.min.js"></script>
<script type="text/javascript" src="lib/zepto.min.js"></script>
<script type="text/javascript" src="js/jquery-litelighter.js"></script>
<script type="text/javascript" src="js/jquery-rebox.js"></script>

3. HTML代码

		<div class="wrapper">
			<div class="header">
				<h1>Rebox - jQuery or Zepto tiny small simple responsive lightbox</h1>
				<ul class="nav">
					<li><a href="#Get_Started" title="Get Started">Get Started</a></li>
					<li><a href="#Examples" title="Examples">Examples</a></li>
					<li><a href="#Options" title="Options">Options</a></li>
					<li><a href="#Methods" title="Methods">Methods</a></li>
					<li><a href="#Events" title="Events">Events</a></li>
				</ul>
			</div>
			<div class="content">
				<p>Ever need a lean, simple, quick lightbox for images that is responsive, delegates, pretty, no required images, includes 
					captions? That is exactly what Rebox does.  Instead of using a rediculous amount of javascript to restrict image sizes 
					within the window, Rebox uses css max-width.  The design requires no images, although if you want to reskin it you can.  
					This keeps the library clean, and simple.</p>
				<p>The final thing you should know.. Rebox comes from REsponsive lightBOX.</p>
				<h2 id="Examples">Examples</h2>
						<!-- ============= example -->
						<div class="example-container">
							<h3>Single Initialization</h3>
							<p>Create a single lightbox, individually on each image:</p>
							<div>
						 		<div id="gallery1" class="gallery">
						 			<a href="media/sample_a.jpg" title="Caption for image A"><img src="media/sample_a_thumb.jpg" /></a>
						 			<a href="media/sample_b.jpg" title="Caption for image B"><img src="media/sample_b_thumb.jpg" /></a>
						 			<a href="media/sample_c.jpg" title="Caption for image C"><img src="media/sample_c_thumb.jpg" /></a>
						 			<a href="media/sample_d.jpg" title="Caption for image D"><img src="media/sample_d_thumb.jpg" /></a>
						 		</div>
							</div>
<pre class="ex code" data-lllanguage="js">
$('#gallery1 a').rebox();
</pre>
						</div>
						<!-- ============= example -->
						<div class="example-container">
							<h3>Gallery Initialization</h3>
							<p>Create a gallery style lightbox:</p>
							<div>
						 		<div id="gallery2" class="gallery">
						 			<a href="media/sample_a.jpg" title="Caption for image A"><img src="media/sample_a_thumb.jpg" /></a>
						 			<a href="media/sample_b.jpg" title="Caption for image B"><img src="media/sample_b_thumb.jpg" /></a>
						 			<a href="media/sample_c.jpg" title="Caption for image C"><img src="media/sample_c_thumb.jpg" /></a>
						 			<a href="media/sample_d.jpg" title="Caption for image D"><img src="media/sample_d_thumb.jpg" /></a>
						 		</div>
							</div>
<pre class="ex code" data-lllanguage="js">
$('#gallery2').rebox({ selector: 'a' });
</pre >
						</div>
						<!-- ============= example -->
						<div class="example-container">
							<h3>Dynamically add images after the fact</h3>
							<p>During page interactions you can add to your container element and new images will be pickedup (But not during an open modal):</p>
							<div>
						 		<div id="gallery3" class="gallery">
						 		</div>
						 		<a href="#" id="gallery3Add">Add an image</a>
							</div>
<pre class="ex code" data-lllanguage="js">
$('#gallery3').rebox({ selector: 'a' });
// don't worry about the following, it just injects a new img..
var counter = 0;
$('#gallery3Add').on('click', function(e){
	e.preventDefault();
	var images = ['a','b','c','d'],
		letter = images[counter++ % images.length];
	$('#gallery3').append(
		'&lt;a href="media/sample_'+ letter +'.jpg" title="Image '+ letter +'"&gt;'+
			'&lt;img src="media/sample_'+ letter +'_thumb.jpg" /&gt;'+
		'&lt;/a&gt; '
		);
});
</pre >
						</div>
						<!-- ============= example -->
						<div class="example-container">
							<h3>Custom Content</h3>
							<p>Using templates you can show images, videos, or anything.  By default only the "image" template is implemented.</p>
							<p>First you need to add a template type.  Each type is a function that is passed the current item that needs to be shown (the thumb image), current Rebox settings, and a callback you must call when your new jquery object is created.  The scope of the callback must be this new element.  If you want the callback to execute immediately just use jquery's .each().</p>
							<p>Next on your gallery links you need to set the template to use with the data attribute: data-rebox-template="video" By default all .</p>
							<p>Using this function approach to templates you're able to do your post creation work to the new content when needed.</p>
							<div>
						 		<div id="gallery4" class="gallery">
						 			<a href="http://www.51qianduan.com//jq22com.webm" title="A racing video" data-rebox-template="video"><img src="media/video_racing_thumb.jpg" /></a>
						 		</div>
							</div>
<pre class="ex code" data-lllanguage="js">
/*
&lt;div id="gallery4" class="gallery"&gt;
	&lt;a href="media/sample_a.jpg" data-rebox-template="video" title="Caption for image A"&gt;
		&lt;img src="media/sample_a_thumb.jpg" /&gt;
	&lt;/a&gt;
&lt;/div&gt;
*/
$('#gallery4 a').rebox({
	templates:{
		video: function($item, settings, callback){
			var url = $item.attr('href').replace(/\.\w+$/,'');
			return $('&lt;video class="'+ settings.theme +'-content" controls preload="metadata" '+
  							'poster="'+url+'.jpg"&gt;'+
						'&lt;source src="'+url+'.webm" type="video/webm" /&gt;'+
						'&lt;source src="'+url+'.mp4" type="video/mp4" /&gt;'+
						'Your browser does not support the HTML5 video tag'+
					'&lt;/video&gt;').on('loadeddata', callback);
		}
	}
});
</pre>
						</div>
						<!-- ============= example -->
						<div class="example-container">
							<h3>Events Example</h3>
							<p>Click through the gallery with your console open to view the events:</p>
							<div>
						 		<div id="gallery5" class="gallery">
						 			<a href="media/sample_a.jpg" title="Caption for image A"><img src="media/sample_a_thumb.jpg" /></a>
						 			<a href="media/sample_b.jpg" title="Caption for image B"><img src="media/sample_b_thumb.jpg" /></a>
						 			<a href="media/sample_c.jpg" title="Caption for image C"><img src="media/sample_c_thumb.jpg" /></a>
						 			<a href="media/sample_d.jpg" title="Caption for image D"><img src="media/sample_d_thumb.jpg" /></a>
						 		</div>
							</div>
<pre class="ex code" data-lllanguage="js">
$('#gallery5').rebox({ selector: 'a' })
	.on('rebox:open', function(e, rx){ console.log(e.type, rx); })
	.on('rebox:close', function(e, rx){ console.log(e.type, rx); })
	.on('rebox:goto', function(e, rx, i, $item, $img){ console.log(e.type, rx, i, $item, $img); });
</pre >
						</div>
				<h2 id="Options">The Options</h2>
<pre class="code" data-lllanguage="js">
{
	theme: 'rebox',        // class name parent gets (for your css)
	selector: null,        // the selector to delegate to, should be to the &lt;a&gt; which contains an &lt;img&gt;
	prev: '&amp;larr;',        // use an image, text, whatever for the previous button
	next: '&amp;rarr;',        // use an image, text, whatever for the next button
	loading: '%',          // use an image, text, whatever for the loading notification
	close: '&amp;times;',      // use an image, text, whatever for the close button
	speed: 600,            // speed to fade in or out
	zIndex: 1000,          // zIndex to apply to the outer container
	cycle: true,           // whether to cycle through galleries or stop at ends
	captionAttr: 'title'   // name of the attribute to grab the caption from
	template: 'image',     // the default template to be used (see templates below)
	templates: {           // define templates to create the elements you need function($item, settings)
		image: function($item, settings, callback){ 
			return $('&lt;img src="'+ $item.attr('href') +'" class="'+ s.theme +'-content" /&gt;').load(callback);
		}
	}
}
</pre>
				<h2 id="Methods">The Methods</h2>
<pre class="code" data-lllanguage="js">
// Initialize a rebox instance
$el.rebox({});
// Enable a rebox, generally you don't have to call this
// but if you want to enable and disable this could be useful
$el.rebox('enable');
// Disable a rebox. Again you generally don't need this
// but if you want to enable and disable this could be useful
$el.rebox('disable');
// Go to the next image in the queue
$el.rebox('next');
// Go to the prev image in the queue
$el.rebox('prev');
// Go to a specific index in the queue
$el.rebox('goto', 4);
// Destroy a rebox
$el.rebox('destroy');
// Get or set an option. When value is provided a Set takes place
// If only the key is provided the value will be retrieved
$el.rebox('option', key, value);
// if an object is passed each setting will be applied
$el.rebox('option', { speed: 500 });
// set global defaults
$.rebox.setDefaults({ theme: 'mytheme' });
</pre>
				<h2 id="Events">The Events</h2>
<pre class="code" data-lllanguage="js">
// when the control is opened
$el.bind('rebox:open', function(e){});
// when the control is closed
$el.bind('rebox:close', function(e){});
// when the control changes image, passes the index as second parameter
$el.bind('rebox:goto', function(e, i){});
// when the control is disabled
$el.bind('rebox:disable', function(e){});
// when the control is destroyed
$el.bind('rebox:destroy', function(e){});
</pre>
			</div>
		</div>
		<!-- <script type="text/javascript" src="lib/zepto.min.js"></script> -->
		<script type="text/javascript">
			$(document).ready(function(){
				// quick routine for scrolling nav
				var $nav = $('.header ul'),
					navoffset = $nav.offset(),
					$navclone = $nav.clone().addClass('scrollnav').appendTo('.header'),
					$window = $(window);
				$window.scroll(function(e){
					if((navoffset.top+50) < $window.scrollTop()){
						if(!$navclone.hasClass('scrolled'))
							$navclone.addClass('scrolled');
					}
					else $navclone.removeClass('scrolled');
				}).scroll();
				// highlight the code
				$('pre.code').litelighter();
				// run the examples
				$('.example-container > pre.ex').each(function(i){
					eval($(this).data('llcode'));
				});
			});
		</script>
<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
</div>



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


热门标签: 滚动 滚动条 页面滚动 滚动插件 滚动条插件 滚动条美化 h5动画导航 h5动画菜单 html5动画导航 html5动画菜单 收缩菜单 收缩导航 右键菜单 导航切换 菜单切换 浮动菜单 浮动导航 滑动导航菜单 滑动导航 滑动菜单 滚动导航菜单 滚动菜单 滚动导航 flash导航菜单 flash导航条 flash导航 flash菜单 flash下拉菜单 flash下拉导航菜单 自动滚动图片轮播 导航菜单 导航条 菜单栏 导航栏 分类导航 响应式导航条 响应式导航 固定导航 固定菜单 全屏滚动 导航菜单插件 导航插件 菜单插件

×
×

注册

官方QQ群

扫描上面二维码加微信群

官方QQ群

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

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