【jquery练习】横向滚动导航菜单

摘要:
--代码开始--˃主页Vector materialVector matematerialVector material//li˃矢量材料˃矢量材料˃矢量材质矢量材质˂!

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>横向滚动导航菜单</title>
<style type="text/css">
body,div,address,blockquote,iframe,ul,ol,dl,dt,dd,li,h1,h2,h3,h4,h5,h6,p,pre,table,caption,th,td,form,legend,fieldset,input,button,select,textarea{margin:0;padding:0;font-weight:normal;font-family:inherit}
ol,ul,li{list-style:none;}
img{margin:0;padding:0;border:none}
table{border-collapse:collapse;}
.cls{clear:both;}
.notxt{text-indent:-9999px;}
body{font-size:14px;font-family:Tahoma;font-family:Arial, Hel,Microsoft YaHei;}
a{color:#000;text-decoration:none;outline:none;blr:expression(this.onFocus=this.blur());}
a:hover{color:#FF0000;}
i { font-style:normal;}

.nav {980px;margin:0 auto; position:relative;}
.nav  ul li {float:left;padding:0 20px;text-align:center;height:40px;line-height:40px;}
.curBg { background:#F00;height:3px;position:absolute;bottom:0;68px;left:0px;}
</style>
</head>
<body>
<!-- 代码开始 -->
<div class="nav">
    <ul>
        <li class="cur"><a href="https://tool.4xseo.com/article/277798.html">首页</a></li>
        <li><a href="https://tool.4xseo.com/article/277798.html">矢量素材</a></li>
        <li><a href="https://tool.4xseo.com/article/277798.html">矢量素材</a></li>
        <li><a href="https://tool.4xseo.com/article/277798.html">矢量素材</a></li>
        <li><a href="https://tool.4xseo.com/article/277798.html">矢量素材</a></li>
        <li><a href="https://tool.4xseo.com/article/277798.html">矢量素材</a></li>
        <li><a href="https://tool.4xseo.com/article/277798.html">矢量素材</a></li>
        <li><a href="https://tool.4xseo.com/article/277798.html">矢量素材</a></li>
        <li><a href="https://tool.4xseo.com/article/277798.html">矢量素材</a></li>
    </ul>
    <div class="curBg"></div>
    <div class="cls"></div>
</div>
<!-- 代码结束 -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    var $liCur = $(".nav ul li.cur"),
      curP = $liCur.position().left,
      curW = $liCur.outerWidth(),
      $slider = $(".curBg"),
      $navBox = $(".nav");
     $targetEle = $(".nav ul li a"),
    $slider.animate({
      "left":curP,
      "width":curW
    });
    $targetEle.mouseenter(function () {
      var $_parent = $(this).parent(),
        _width = $_parent.outerWidth(),
        posL = $_parent.position().left;
      $slider.stop(true, true).animate({
        "left":posL,
        "width":_width
      }, "fast");
    });
    $navBox.mouseleave(function (cur, wid) {
      cur = curP;
      wid = curW;
      $slider.stop(true, true).animate({
        "left":cur,
        "width":wid
      }, "fast");
    });
})
</script>
</body>
</html>






























免责声明:文章转载自《【jquery练习】横向滚动导航菜单》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇intel 系列的PC机处理器是大端的还是小端的?nm命令 查看一个可执行文件或者库的依赖库下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

jQuery(二)

二、jQuery的选择器 我们以前在CSS中学习的选择器有: 今天来学习一下jQuery 选择器。 jQuery选择器是jQuery强大的体现,它提供了一组方法,让我们更加方便的获取到页面中的元素。 1、jQuery 的基本选择器 代码如下: <!DOCTYPE html> <html lang="en"> <...

利用jquery 实现hover的div显隐

通常要用到jq的时候这两个抓取对象没有父子级关系,但直接用jquery中的hover事件时,当鼠标移出绑定元素就会执行消失动作,因此: var timer=0; $('#sad').hover(function(){ $('#reply').show(); },function(){ timer=setTimeout(functio...

jquery参考手册

jQuery 选择器 选择器 实例 选取 * $("*") 所有元素 #id $("#lastname") 的元素 .class $(".intro") 的所有元素 .class,.class $(".intro,.demo") class 为 "intro" 或 "demo" 的所有元素 element $("p")...

python_14(js)

第1章 图片方法 1.1 设置背景图:1.2 背景图问题:1.3 background-repeat; noa-repe 1.4 background-attachment: fixed1.5 background-position 1.6 background-position-x 1.7 截取局部1.7.1 透明色第2章 定位 2.1 定义形式2.2...

qt 界面去掉系统边框2.0版

之前的一版存在bug。如果将鼠标放移动到界面内某个可点击的widget上(如:QPushButton)上,按住鼠标左键不放,界面可能会出现界面非预期移动的问题。 那是因为当鼠标移动到可点击的widget(如:QPushButton)上时,mousePressEvent这个信号被可点击的widget拦截了,所以包含这个widget的界面的mousePress...

cesium贴地代码

//贴地 // Cesium.sampleTerrain( // cesiumInit.terrainProvider, // 0, // positions//所有点的arry // ).then(function (updatedCartographics) { // console.log(updatedCartog...