网络编程 
首页 > 网络编程 > 浏览文章

jQuery实现导航样式布局操作示例【可自定义样式布局】

(编辑:jimmy 日期: 2024/5/8 浏览:3 次 )

本文实例讲述了jQuery实现导航样式布局操作。分享给大家供大家参考,具体如下:

1. 导航Html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>www.jb51.net 导航样式布局</title>
  <link rel="stylesheet" href="style.css" rel="external nofollow" >
  <script src="/UploadFiles/2021-04-02/jquery.min.js">

2. 导航css布局代码

@charset "utf-8";
body{
  margin: 0;
}
.list{
  list-style-type:none;
  margin: 0;
  padding: 0;
  font-size: 14px;
  color: #fff;
  width: 500px;
  margin:50px auto;
}
.list li{
  float: left;
  width: 100px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  background-color: #333333;
  cursor: pointer;
}
.nav{
  /*list-style:none;*/
  margin:0;
  padding:0;
  display:none;
/*color:color ;*/
  /*background-color: ;*/
}

3. 导航js自定义布局代码

/**
 * Created by Administrator on 2016/5/23.
 */
;(function ($) {
  $.fn.extend(
    {
     'nav':function (color,fonts) {
     $(this).find('.nav').css({
          'list-style':'none',
          'margin':0,
          'padding':0,
          'display':'none',
          'color':color,
          'font-size':fonts
        });
        $(this).find('.nav').parent('li').hover(function () {
          $(this).find('.nav').slideDown('normal');
        },function () {
          $(this).find('.nav').stop().slideUp('normal');
        })
        return this;
      }
    }
  );
})(jQuery);

使用在线HTML/CSS/JavaScript代码运行工具:http://tools.jb51.net/code/HtmlJsRun测试,效果如下:

jQuery实现导航样式布局操作示例【可自定义样式布局】

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery切换特效与技巧总结》、《jQuery扩展技巧总结》、《jQuery常用插件及用法总结》、《jQuery拖拽特效与技巧总结》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》及《jquery选择器用法总结》

希望本文所述对大家jQuery程序设计有所帮助。

上一篇:js实现敏感词过滤算法及实现逻辑
下一篇:jQuery实现菜单的显示和隐藏功能示例
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网