Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

顶部导航固定的建议

[复制链接]
aoove 发表于 2013-4-26 10:22:31 | 显示全部楼层 |阅读模式
顶部导航固定只在论坛可以设置,在论坛风格的个人空间,顶部导航固定也不可以设置。找到了js代码不知道怎么设置。。。
  1. function fixed_top_nv(eleid, disbind) {
  2.         this.nv = eleid && $(eleid) || $('nv');
  3.         this.openflag = this.nv && BROWSER.ie != 6;
  4.         this.nvdata = {};
  5.         this.init = function (disattachevent) {
  6.                 if(this.openflag) {
  7.                         if(!disattachevent) {
  8.                                 var obj = this;
  9.                                 _attachEvent(window, 'resize', function(){obj.reset();obj.init(1);obj.run();});
  10.                                 var switchwidth = $('switchwidth');
  11.                                 if(switchwidth) {
  12.                                         _attachEvent(switchwidth, 'click', function(){obj.reset();obj.openflag=false;});
  13.                                 }
  14.                         }

  15.                         var next = this.nv;
  16.                         try {
  17.                                 while((next = next.nextSibling).nodeType != 1 || next.style.display === 'none') {}
  18.                                 this.nvdata.next = next;
  19.                                 this.nvdata.height = parseInt(this.nv.offsetHeight, 10);
  20.                                 this.nvdata.width = parseInt(this.nv.offsetWidth, 10);
  21.                                 this.nvdata.left = this.nv.getBoundingClientRect().left - document.documentElement.clientLeft;
  22.                                 this.nvdata.position = this.nv.style.position;
  23.                                 this.nvdata.opacity = this.nv.style.opacity;
  24.                         } catch (e) {
  25.                                 this.nvdata.next = null;
  26.                         }
  27.                 }
  28.         };

  29.         this.run = function () {
  30.                 var fixedheight = 0;
  31.                 if(this.openflag && this.nvdata.next){
  32.                         var nvnexttop = document.body.scrollTop || document.documentElement.scrollTop;
  33.                         var dofixed = nvnexttop !== 0 && document.documentElement.clientHeight >= 15 && this.nvdata.next.getBoundingClientRect().top - this.nvdata.height < 0;
  34.                         if(dofixed) {
  35.                                 if(this.nv.style.position != 'fixed') {
  36.                                         this.nv.style.borderLeftWidth = '0';
  37.                                         this.nv.style.borderRightWidth = '0';
  38.                                         this.nv.style.height = this.nvdata.height + 'px';
  39.                                         this.nv.style.width = this.nvdata.width + 'px';
  40.                                         this.nv.style.top = '0';
  41.                                         this.nv.style.left = this.nvdata.left + 'px';
  42.                                         this.nv.style.position = 'fixed';
  43.                                         this.nv.style.zIndex = '199';
  44.                                         this.nv.style.opacity = 0.85;
  45.                                 }
  46.                         } else {
  47.                                 if(this.nv.style.position != this.nvdata.position) {
  48.                                         this.reset();
  49.                                 }
  50.                         }
  51.                         if(this.nv.style.position == 'fixed') {
  52.                                 fixedheight = this.nvdata.height;
  53.                         }
  54.                 }
  55.                 return fixedheight;
  56.         };
  57.         this.reset = function () {
  58.                 if(this.nv) {
  59.                         this.nv.style.position = this.nvdata.position;
  60.                         this.nv.style.borderLeftWidth = '';
  61.                         this.nv.style.borderRightWidth = '';
  62.                         this.nv.style.height = '';
  63.                         this.nv.style.width = '';
  64.                         this.nv.style.opacity = this.nvdata.opacity;
  65.                 }
  66.         };
  67.         if(!disbind && this.openflag) {
  68.                 this.init();
  69.                 _attachEvent(window, 'scroll', this.run);
  70.         }
  71. }
复制代码
hjj6650551 发表于 2013-4-26 10:26:25 | 显示全部楼层
能否固定帖子标题?  跟百度贴吧一样!
回复

使用道具 举报

SkyToo 发表于 2013-4-26 10:28:03 | 显示全部楼层
个人到不希望是固定的,但位置要换一下,把现在的导航位置换到最上面跟“设为首页、收藏本站”这一行合并到一起,目前的浮动顶部导航效果太2了,,感觉好生硬,没有流畅感
回复

使用道具 举报

 楼主| aoove 发表于 2013-4-26 10:34:55 | 显示全部楼层
hjj6650551 发表于 2013-4-26 10:26
能否固定帖子标题?  跟百度贴吧一样!

这个建议太好了
回复

使用道具 举报

 楼主| aoove 发表于 2013-4-26 10:38:24 | 显示全部楼层
SkyToo 发表于 2013-4-26 10:28
个人到不希望是固定的,但位置要换一下,把现在的导航位置换到最上面跟“设为首页、收藏本站”这一行合并到 ...

如果导航固定到顶部 导航 的宽度 是100% 和屏幕一样宽  就好看点了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-5-16 06:27 , Processed in 0.050482 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表