jQuery小盒子菜单效果特效代码

版权:原创 更新时间:1年以上
[该文章底部包含文件资源,可根据自己情况,决定是否下载资源使用,时间>金钱,如有需要,立即查看资源]

以下是 jQuery小盒子菜单效果特效代码 的示例演示效果:

当前平台(PC电脑)
  • 平台:

部分效果截图1:

jQuery小盒子菜单效果特效代码

部分效果截图2:

jQuery小盒子菜单效果特效代码

HTML代码(index.html):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>Little Boxes Menu with jQuery</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="description" content="Little Boxes Menu or Navigation with jQuery - radnomly animate the menu items to show content, accodion like boxes menu" />
        <meta name="keywords" content="jquery, boxes, menu, navigation, animate"/>
        <link rel="stylesheet" href="css/style.css" type="text/css" media="screen"/>
        <style>
            *{
                margin:0;
                padding:0;
            }
            body{
                background:#E4FFCF url(wood.jpg) no-repeat top center;
                font-family:Futura, "Century Gothic", AppleGothic, sans-serif;
                overflow:hidden;
            }
            h1{
                color:#fff;
                margin:40px 0px 20px 40px;
                text-shadow:1px 1px 1px #555;
                font-weight:normal;
            }
            a.back{
                position:absolute;
                bottom:5px;
                right:5px;
            }
            .reference{
                position:absolute;
                bottom:5px;
                left:5px;
            }
            .reference p a, a.back{
                text-transform:uppercase;
                text-shadow:1px 1px 1px #fff;
                color:#666;
                text-decoration:none;
                font-size:16px;
                font-weight:bold;
            }
            .reference p a:hover, a.back:hover{
                color:#000;
            }
        </style>
    </head>
    <body>
        <div class="title">
            <h1>Little Boxes Menu with jQuery</h1>
        </div>
        <div id="content">
            <div class="reference">
                <p><a href="#">Photos from williamcho's photostream on Flickr</a></p>
            </div>

            <a class="back" href="#">Back to Codrops</a>
            <div id="littleBoxes" class="littleBoxes">
                <div class="boxlink bg1" style="top:0px;left:0px;">
                    <a href="">About</a>
                    <div class="boxcontent">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, 
                            sed do eiusmod tempor incididunt ut labore et dolore magna
                            aliqua. Ut enim ad minim veniam, quis nostrud exercitation
                            ullamco laboris nisi ut aliquip ex ea commodo consequat.
                        </p>
                    </div>
                </div>
                <div class="bg5" style="background-position:-90px 0;top:0px;left:95px;"></div>
                <div class="bg5" style="background-position:-180px 0;top:0px;left:190px;"></div>
                <div class="bg5" style="background-position:-270px 0;top:0px;left:285px;"></div>

                <div class="bg5" style="background-position:0 -90px;top:95px;left:0px;"></div>
                <div class="boxlink bg2" style="top:95px;left:95px;">
                    <a href="">Menu</a>
                    <div class="boxcontent">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,
                            sed do eiusmod tempor incididunt ut labore et dolore magna
                            aliqua. Ut enim ad minim veniam, quis nostrud exercitation
                            ullamco laboris nisi ut aliquip ex ea commodo consequat.
                        </p>
                    </div>
                </div>
                <div class="bg5" style="background-position:-180px -90px;top:95px;left:190px;"></div>
                <div class="bg5" style="background-position:-270px -90px;top:95px;left:285px;"></div>

                <div class="bg5" style="background-position:0 -180px;top:190px;left:0px;"></div>
                <div class="bg5" style="background-position:-90px -180px;top:190px;left:95px;"></div>
                <div class="boxlink bg3" style="top:190px;left:190px;">
                    <a href="">Chef</a>
                    <div class="boxcontent">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,
                            sed do eiusmod tempor incididunt ut labore et dolore magna
                            aliqua. Ut enim ad minim veniam, quis nostrud exercitation
                            ullamco laboris nisi ut aliquip ex ea commodo consequat.
                        </p>
                    </div>
                </div>
                <div class="bg5" style="background-position:-270px -180px;top:190px;left:285px;"></div>

                <div class="bg5" style="background-position:0 -270px;top:285px;left:0px;"></div>
                <div class="bg5" style="background-position:-90px -270px;top:285px;left:95px;"></div>
                <div class="bg5" style="background-position:-180px -270px;top:285px;left:190px;"></div>
                <div class="boxlink bg4" style="top:285px;left:285px;">
                    <a href="">Contact</a>
                    <div class="boxcontent">
                        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,
                            sed do eiusmod tempor incididunt ut labore et dolore magna
                            aliqua. Ut enim ad minim veniam, quis nostrud exercitation
                            ullamco laboris nisi ut aliquip ex ea commodo consequat.
                        </p>
                    </div>
                </div>
            </div>
        </div>
        <!-- The JavaScript -->
        <script type="text/javascript" src="jquery-3.4.1.min.js"></script>
        <script type="text/javascript" src="jquery.easing.1.3.js"></script>
       <script type="text/javascript">
            $(function() {
                /* object to save the initial positions of each box */
                var divinfo = {"initial": []};
                /* index of the selected / clicked box */
                var current = -1;

                /* we save the index,top and left of each one of the boxes */
                $('#littleBoxes > div').each(function(){
                    var $this = $(this);
                    var initial = {
                                'index' : $this.index(),
                                'top'     : $this.css('top'),
                                'left'     : $this.css('left')
                    };
                    divinfo.initial.push(initial);
                });

                /* clcik event for the anchors inside of the boxes */
                $('#littleBoxes a').bind('click',function(e){
                        var $this         = $(this);
                        var $currentBox    = $this.parent();
                        /* set a z-index lower than all the other boxes,
                        to see the other boxes animation on the top*/
                        $currentBox.css('z-index','1');

                        /* if we are clicking on a expanded box : */
                        if(current == $currentBox.index()){
                            /* put it back (decrease width,height, and set the top and left like it was before).
                            the previous positions are saved in the divinfo obj*/
                            $currentBox.stop().animate({
                                    'top'         : divinfo.initial[$currentBox.index()].top,
                                    'left'        : divinfo.initial[$currentBox.index()].left,
                                    'width'     : '90px',
                                    'height'    : '90px'
                            },800,'easeOutBack').find('.boxcontent').fadeOut();


                            $('#littleBoxes > div').not($currentBox).each(function(){
                                var $ele         = $(this);
                                var elemTop     = divinfo.initial[$ele.index()].top;
                                var elemLeft     = divinfo.initial[$ele.index()].left;
                                $ele.stop().show().animate({
                                    'top'         : elemTop,
                                    'left'        : elemLeft,
                                    'opacity'    : 1
                                },800);
                            });
                            current = -1;
                        }
                        /* if we are clicking on a small box : */
                        else{
                            /* randomly animate all the other boxes.
                            Math.floor(Math.random()*601) - 150 gives a random number between -150 and 450.
                            This range is considering the initial lefts/tops of the elements. It's not the exact right
                            range, since we would have to calculate the range based on each one of the boxes. Anyway, it
                            fits our needs...
                            */
                            $('#littleBoxes > div').not($currentBox).each(function(){
                                var $ele = $(this);
                                $ele.stop().animate({
                                    'top' : (Math.floor(Math.random()*601) - 150) +'px',
                                    'left': (Math.floor(Math.random()*601) - 150) +'px',
                                    'opacity':0
                                },800,function(){
                                    $(this).hide();
                                });
                            });

                            /* expand the clicked one. Also, fadeIn the content (boxcontent)
                            if you want it to fill the space of the littleBoxes container,
                            then these are the right values */
                            var newwidth     = 379;
                            var newheight     = 379;
                            $currentBox.stop().animate({
                                'top'     : '0px',
                                'left'    : '0px',
                                'width' : newwidth +'px',
                                'height': newheight+'px'
                            },800,'easeOutBack',function(){
                                current = $currentBox.index();
                                $(this).find('.boxcontent').fadeIn();
                            });


                        }
                        e.preventDefault();
                });
            });
        </script>
    </body>
</html>







CSS代码(style.css):

.littleBoxes{width:350px;height:350px;margin:0 auto;position:relative;}
.littleBoxes > div{position:absolute;width:90px;height:90px;text-align:center;border:2px solid white;overflow:hidden;background-color:#f7f7f7;-moz-box-shadow:0px 0px 3px #555;-webkit-box-shadow:0px 0px 3px #555;box-shadow:0px 0px 3px #555;background-position:center center;z-index:999;}
.littleBoxes div a{text-transform:uppercase;font-size:18px;font-weight:bold;letter-spacing:-1px;display:block;line-height:90px;text-decoration:none;color:#fff;background:#91EF4A url(../bgItem.png) repeat-x top left;outline:none;text-shadow:1px 1px 1px #888;-moz-box-shadow:1px 1px 3px #777;-webkit-box-shadow:1px 1px 3px #777;box-shadow:1px 1px 3px #777;}
.littleBoxes div.boxcontent{width:334px;height:246px;text-align:left;padding:10px;font-size:16px;background-color:#f0f0f0;border:2px solid #fff;margin:10px 0px 0px 10px;text-shadow:1px 1px 1px #fff;-moz-box-shadow:1px 1px 3px #777;-webkit-box-shadow:1px 1px 3px #777;box-shadow:1px 1px 3px #777;opacity:0.8;display:none;}
.bg1,.bg2,.bg3,.bg4{background-repeat:no-repeat;}
.bg1{background-image:url(../images/1.jpg);}
.bg2{background-image:url(../images/2.jpg);}
.bg3{background-image:url(../images/3.jpg);}
.bg4{background-image:url(../images/4.jpg);}
.bg5{background-image:url(../images/5.jpg);}
附件:下载该文件资源,减少时间成本(增值服务)
留言
该资源可下载
File Source
.rar
1.00 MB
Html Js 菜单导航特效2
最新结算
HTML5 3D效果网页视频背景代码
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
软件概要设计说明书Word下载
类型: .docx 金额: CNY 0.38¥ 状态: 待结算 详细>
软件概要设计说明书Word下载
类型: .docx 金额: CNY 3.02¥ 状态: 待结算 详细>
.net c#获取声卡信息,声卡数量
类型: .rar 金额: CNY 30.96¥ 状态: 待结算 详细>
.net c#获取声卡信息,声卡数量
类型: .rar 金额: CNY 3.87¥ 状态: 待结算 详细>
.net c#获取电脑的安装软件列表信息,包含名称和版本号
类型: .rar 金额: CNY 30.96¥ 状态: 待结算 详细>
.net c#获取电脑的安装软件列表信息,包含名称和版本号
类型: .rar 金额: CNY 3.87¥ 状态: 待结算 详细>
.net c#获取电脑显示适配器信息
类型: .rar 金额: CNY 30.96¥ 状态: 待结算 详细>
.net c#获取电脑的安装软件列表信息,包含名称和版本号
类型: .rar 金额: CNY 3.87¥ 状态: 待结算 详细>
.net c#获取电脑的安装软件列表信息,包含名称和版本号
类型: .rar 金额: CNY 30.96¥ 状态: 待结算 详细>
各执行环节公正透明,帮助企业完成从赛制策划、活动推广、评委评选到版权转让等系列工作,专业、高效、值得信赖。平均每场赛事可征集到数百至数千组源码作品
合作伙伴
联系我们
  • 邮箱:raozetian@hotmail.com
Copyright 2023-2024 eeigg.com·皖ICP备2024038726号-1
打赏文章