jQuery实现动画滑动二级菜单

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jquery-3.2.1.js" type="text/javascript"></script>
    <script src="滑动动画.js" type="text/javascript"></script>
    <link rel="stylesheet" href="滑动动画.css" type="text/css"/>
</head>
<body>
<div class="header">
    <ul>
        <li class="nav"><a href="#">one</a></li>
        <li class="nav"><a href="#">two</a></li>
        <li class="nav"><a href="#">three</a></li>
        <li class="nav"><a href="#">four</a></li>
    </ul>
</div>
<div class="big">
    <div class="main">
        <div class="a"></div>
        <div class="b"></div>
        <div class="c"></div>
        <div class="d"></div>
    </div>
</div>
</body>
</html>
*{
    margin:0;
    padding:0;
}
.header{
    background-color:aqua;
    height: 40px;

}
ul{
    list-style: none;
}
ul li{
    float: left;
    text-align: center;
    line-height: 40px;
    border-right: 1px solid white;
}
a{
    text-decoration:none;
    color: white;
    display: block;
    padding: 0 20px;
}
ul li a:hover {
    background-color: white;
    color: aqua;
}
.big{
    width:100%;
    overflow: hidden;
    height:0;
    top:40px;
}
.main{
    width: 400%;
    height:500px;
}
.a{
    width:25%;
    height: 500px;
    background-color: yellow;
    float:left;
}
.b{
    width:25%;
    height: 500px;
    background-color: red ;
    float:left;
}
.c{
    width:25%;
    height: 500px;
    background-color: black ;
    float:left;
}
.d{
    width:25%;
    height: 500px;
    background-color: blue;
    float:left;
}
$(function () {
    $(".header").on("click","li",function () {
        var curIndex = $(this).index(), mlValue = "-" + curIndex * 100 + "%";
        /*index()获取header里的li,并确定为第几个然后返回数字*/
        if ($(".big").hasClass("active")) {
            $(".main").animate({marginLeft: mlValue});
        }
        else{
            $(".main").css({marginLeft:mlValue});
            $(".big").animate({height:"500px"}).addClass("active");
        }
    });
});
时间: 2024-11-05 12:30:44

jQuery实现动画滑动二级菜单的相关文章

Jquery垂直下拉二级菜单

自己做了一个基于Jquery 的垂直下拉二级菜单功能,直接看图: Html的代码如下: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>垂直下拉菜单</title> <meta name="viewport" content="width=device-width, initial-scale=1"

jQuery show hide方法 二级菜单

1 <!DOCTYPE html> 2 <html lang="en"> 3 4 <head> 5 <meta charset="UTF-8"> 6 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 7 <meta http-equiv="X-UA-Compat

用jquery插件写一个小米官网左侧二级菜单

知识点:静态布局思路,jquery动态布局,代码格式规范,jquery插件调用, 鼠标滑动二级菜单构建. html代码: <div id="Tz_banner"> <ul> <li class="firstLi">手机 电话卡 <div class="info"> <ul> <li><a class="title" href="#"

jquery二级菜单。显示了jquery的方便

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" con

jquery实现后台系统左侧菜单的点击展开/收缩二级菜单效果

html: <div class="col-sm-3 col-md-2 sidebar"> <div class="totalt"><a>系统管理系统</a></div> <ul class="menu"> <li class="title"> <a class="item item1"><span cla

jQuery滑动导航菜单

<!DOCTYPE HTML> <html> <head> <meta charset="UTF-8" /> <meta name="author" content="abangsir" /> <title>jQuery弹性滑动导航菜单</title> <style type="text/css"> body{ font-famil

jQuery 二级菜单,一次显示一个小类 鼠标点击显示小类

jQuery 二级菜单,一次显示一个小类 鼠标点击显示小类 本例有另外2个关联案例,演示地址分别为2.php,3.php 演示 XML/HTML Code <div class="arrowlistmenu"> <h3 class="menuheader expandable">表单</h3> <ul class="categoryitems"> <li><a href="

jQuery层动画定位滑动效果代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>jQuery层动画定位滑动</title&

制作动画二级菜单

下面是学习慕课网上的制作动作二级菜单的HTML代码 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4