基于jquery實現鼠標滾動顯示導航菜單代碼



37 144 49



特效描述:基于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.cqetom.live//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

加群請備注:從官網了解到

老夫子电子