利用jQuery css实现网站页面导航特效



如需定制开发(网站开发、二次开发)在线咨询,请点击>> QQ:753511799

110 437 146



特效描述:利用jQuery css实现 网站页面 导航特效。利用jQuery css实现网站页面导航特效

代码结构

1. 引入CSS

<link rel="stylesheet" href="css/zzsc.css" type="text/css" media="screen, projection" />

2. 引入JS

<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<script type="text/javascript" src="js/jquery-1.9.0.min.js"></script>

3. HTML代码

<!--<ul class="sminqu">
    <li class='serv'><a href="#">&#7463;</a></li>
    <li><a href="#">Предисловие</a></li>
	<li><a href="#">Подготовка шаблона</a></li>
	<li><a href="#">Слои-джедаи</a></li>
	<li><a href="#">Работает?</a></li>
    <li class='serv'><a href="#" >&#7456;</a></li>
</ul>-->
<ul class="sminqu">
    <li><img src="images/appicns_Chrome.png" /></li>
    <li><img src="images/appicns_Firefox.png" /></li>
    <li><img src="images/appicns_Safari.png" /></li>
    <li><img src="images/appicns_Skype.png" /></li>
</ul>
<div id="wrapper">
	<header id="header">
		<strong>Header:</strong> Lorem ipsum dolor sit amet, consectetur 
	adipiscing elit. Cras tortor. Praesent dictum, libero ut tempus dictum, 
	neque eros elementum mauris, quis mollis arcu velit ac diam. Etiam neque. 
	Quisque nec turpis. Aliquam arcu nulla, dictum et, lacinia a, mollis in, 
	ante. Sed eu felis in elit tempor venenatis. Cum sociis natoque penatibus et 
	magnis dis parturient montes, nascetur ridiculus mus. Ut ultricies porttitor 
	purus. Proin non tellus at ligula fringilla tristique. Fusce vehicula quam. 
	Curabitur vel tortor vitae pede imperdiet ultrices. Sed tortor.
	</header><!-- #header-->
	<div id="content">
<p data-mnav="0">empora, dolores, iure amet voluptate expedita odio labore 
aperiam cupiditate iste modi magnam possimus hic sit odit dolor error repellat 
porro.</p>
<p data-mnav="1">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum, 
totam quidem suscipit nihil sunt vitae est itaque expedita laudantium 
laboriosam. Culpa, repellendus libero accusantium sint molestias quidem maiores 
voluptates quis!</p>
<p data-mnav="2">Lorem ipsum dolor sit amet, consectetur adipisicing elit. 
Doloribus, asperiores, inventore exercitationem eligendi temporibus ipsum facere 
iure natus obcaecati mollitia. Eaque deleniti est sunt totam odit neque quam. 
Officiis, ipsa?</p>
<p data-mnav="3">Lorem ipsum dolor sit amet, consectetur adipisicing elit. 
Impedit, excepturi maxime magnam! Quo, possimus commodi alias veniam labore 
velit deserunt magnam odit eum autem perferendis voluptate explicabo facere! 
Quod, ipsum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt, incidunt, 
amet, magni, cupiditate ad nam voluptates autem nemo repudiandae eveniet 
reprehenderit enim dolore sed officiis voluptatum sequi hic veniam perspiciatis.</p>
	</div><!-- #content-->
</div><!-- #wrapper -->
<script>
/*if ($('.sm').length > 0) {
$('.sminqu li').each(function(i) { //ul.menu li > a
if(i!=0 && i!=$('ol.cbp-vimenu a').length-1){
    $(this).wrapInner("<a href='#'></a>").click(function(){ 
		$("html, body").animate({
			"scrollTop": $('#nav'+i).offset().top-25
		},"slow");
		return false;
	});
}
if (i == 0){$(this).click(function(){$("html, body").animate({"scrollTop":0},"slow");return false;});}
if(i==$('ol.cbp-vimenu a').length-1){
	$(this).click(function(){$("html, body").animate({"scrollTop":$(document).height()},"slow");return false;});
}
});
$(window).scroll(function(){
$('ol.cbp-vimenu a').each(function(i) { 
if(i!=0 && i!=$('ol.cbp-vimenu a').length-1){
	if ($(window).scrollTop() >= $('#nav'+i).offset().top-25){
        $(this).addClass('cbp-curr');
    }
    else
    {
        $(this).removeClass('cbp-curr');
    }
}
});
});
};*/
// the semi-colon before function invocation is a safety net against concatenated
// scripts and/or other plugins which may not be closed properly.
;(function ( $, window, document, undefined ) {
    // undefined is used here as the undefined global variable in ECMAScript 3 is
    // mutable (ie. it can be changed by someone else). undefined isn't really being
    // passed in so we can ensure the value of it is truly undefined. In ES5, undefined
    // can no longer be modified.
    // window and document are passed through as local variable rather than global
    // as this (slightly) quickens the resolution process and can be more efficiently
    // minified (especially when both are regularly referenced in your plugin).
    // Create the defaults once
    var pluginName = "minqu",
        defaults = {
            autofill: true,
            backlight: true
        };
    // The actual plugin constructor
    function Plugin( element, options ) {
        this.element = element;
        // jQuery has an extend method which merges the contents of two or
        // more objects, storing the result in the first object. The first object
        // is generally empty as we don't want to alter the default options for
        // future instances of the plugin
        this.options = $.extend( {}, defaults, options );
        this._defaults = defaults;
        this._name = pluginName;
        this.init();
    }
    Plugin.prototype = {
        init: function() {
            // Place initialization logic here
            // You already have access to the DOM element and
            // the options via the instance, e.g. this.element
            // and this.options
            // you can add more functions like the one below and
            // call them like so: this.yourOtherFunction(this.element, this.options).
            var $thiselem = this.element;
            if($('*[data-mnav]').length > 0){
                if($('> li', this.element).length > 0){
                $('> li', this.element).each(function(i) { 
                    $(this).wrapInner("<a href='#'></a>").click(function(){ 
                        $("html, body").animate({
                            "scrollTop": $('*[data-mnav="'+i+'"]').offset().top-25
                        },"slow");
                        return false;
                    });
                });
                }
                else if (this.options.autofill){
                    $('*[data-mnav]').each(function(i) {
                        $('> li:last a', $thiselem).append('<li><a href="#">'+i+'</a></li>')
                        .click(function(){ 
                            $("html, body").animate({
                                "scrollTop": $('*[data-mnav="'+i+'"]').offset().top-25
                            },"slow");
                            return false;
                        });
                    });                    
                }
            }else {console.log("minqu: There is no &laquo;data-mnav&raquo; anchors on this page")}
            if (this.options.backlight){
                $(window).scroll(function(){
                $('> li', $thiselem).each(function(i) {
                    if ($(window).scrollTop() >= $('*[data-mnav='+i+']').offset().top-25){
                        $(this).addClass('sminqu-curr');
                    }
                    else
                    {
                        $(this).removeClass('sminqu-curr');
                    }
                });
                }); 
            }          
            /*if(this.options.tpbt){
                $(this.element).append('<li name="tpbt"><a href="#">'+this.options.tpbt+'</a></li>')
                .click(function(){$("html, body").animate({"scrollTop":0},"slow");return false;});
            }
            if(this.options.dnbt){
                $(this.element).append('<li name="dnbt"><a href="#">'+this.options.dnbt+'</a></li>')
                .click(function(){$("html, body").animate({"scrollTop":$(document).height()},"slow");return false;});
            }*/                        
        },
        yourOtherFunction: function(el, options) {
            // some logic
        }
    };
    // A really lightweight plugin wrapper around the constructor,
    // preventing against multiple instantiations
    $.fn[pluginName] = function ( options ) {
        return this.each(function () {
            if (!$.data(this, "plugin_" + pluginName)) {
                $.data(this, "plugin_" + pluginName, new Plugin( this, options ));
            }
        });
    };
})( jQuery, window, document );
$('.sminqu').minqu({
    autofill: true,
    backlight: true
});
</script>
<div style="text-align:center;clear:both">
</div>



用户评论
大牛,别默默的看了,快登录帮我点评一下吧!:)      登录 | 注册
小小的太阳
关注
TA的相关作品 >>更多


热门标签: 滚动导航菜单 导航切换 二级导航菜单 滚动切换 下拉导航菜单 图片滚动 图片切换 竖直导航菜单 文字滚动 文字切换 图标导航菜单 背景切换 固定导航菜单 图片文字滚动 手风琴 侧边导航菜单 全屏滚动 选项卡自动切换 树形导航菜单 页面滚动 视频切换 网址导航菜单 列表切换 导航菜单插件 渐隐切换 文字导航菜单 全屏切换 切换按钮 缩放切换 滚动流动 滚动导航菜单 滑动导航菜单 浮动导航菜单 导航切换 右键菜单 收缩导航菜单 html5动画导航菜单 flash导航菜单 滚动切换 滑动选项卡切换 自动滚动图片轮播 选项卡切换 滑动手风琴 导航菜单导航条

×
×
51前端

注册

×
绑定手机

请绑定手机号,在继续操作

×
单次下载支付

应付金额:279

支付完成后,回到下载页面,在进行下载

官方QQ群
意见反馈
qq群

扫描上面二维码加微信群

官方QQ群

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

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