- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
第一次发帖。希望大家能帮忙。将不胜感激,我相信我会学到一些东西。此外,如果您在下面看到我的问题之外的任何其他冗余,请随时给我一个关于编码实践的新问题。我需要尽快学习尽可能多的东西。关于问题!
我有两个独立的脚本,但我无法让它们完美运行。
首先是“magicline”脚本。这会根据您导航到的页面在导航下方设置一条线。
我想不通的是:1) 如何消除因添加 margin-left:""分隔导航项而导致的额外线宽。
其次,用jquery加载页面内容。我希望能够通过调用支持页面部分的内容来加载我的 4 个独立页面。截至目前,有两个问题。一个是,无论您单击哪个页面,它都会一遍又一遍地重新加载相同的内容。此外,即使 URL 更新到正确的页面,导航“当前页面”颜色标记也不会跟随。
为了更容易理解,我在这里运行了一个现场演示: http://www.youngsaye.net/v2/
任何帮助将不胜感激。
谢谢!
最佳答案
在查看页面时,我看到了以下内容:
1) 魔术线脚本根据类为“current_page_item”的元素确定下划线的宽度。
因为这都是 javascript。您需要设置菜单 anchor /链接以包含将 current_page_item 类更新为所选项目并将其从上一个项目中删除的 javascript。这也应该更新您的突出显示问题,因为它似乎是 css 样式。
一个基本的脚本如下所示:
function updateCurrent(e) {
$('.current_page_item').removeClass('current_page_item');
$(e).parent('li').addClass('current_page_item');
}
你所有的 anchor 都会有一个 onClick 看起来像:
<a href="print.html" onclick="updateCurrent(this);">Print</a>
2) 我没有完全理解你第二个问题的要点。当我浏览它时,导航看起来指向正确的内容。
编辑下面我添加的评论:
$('#topnav li a').click(function(){
// Update the current item.
$('.current_page_item').removeClass('current_page_item');
$(this).parent('li').addClass('current_page_item');
var toLoad = $(this).attr('href')+' #content';
$('#content').hide('fast',loadContent);
window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
function loadContent() {
$('#content').load(toLoad,'',showNewContent())
}
function showNewContent() {
$('#content').show('normal',hideLoader());
}
function hideLoader() {
$('#load').fadeOut('normal');
}
return false;
});
编辑第 2 部分:我发现您仍然无法让魔术线忽略您的宽度,您需要做的是在单击 anchor 时,也应该完成您在初始加载时应用的相同数学运算。
更新后的魔法线 js 应该如下所示:
// DOM Ready
$(function() {
$("#topnav").append("<li id='magic-line'></li>");
// get the left margin of current page item
var marg = parseInt($(".current_page_item a").css("marginLeft"));
/* Cache it */
var $magicLine = $("#magic-line");
$magicLine
.width($(".current_page_item a").width())
.css("left", $(".current_page_item a").position().left + marg)
.data("origLeft", $magicLine.position().left)
.data("origWidth", $magicLine.width());
$("#topnav li").find("a").click(
$el = $(this);
// Do the math for each click
leftPos = $el.position().left + marg;
newWidth = $el.parent().width() - marg;
$magicLine.stop().animate({
left: leftPos,
width: newWidth
});
}, function() {
$magicLine.stop().animate({
left: $magicLine.data("origLeft"),
width: $magicLine.data("origWidth")
});
});
/* Kick IE into gear */
$(".current_page_item_two a").mouseenter();
});
关于javascript - jquery 将内容加载到 div 和 magicline,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12185549/
我有一个只有顶级元素的基本导航。有一个超大的背景图像(导航是 100 像素高,背景图像是 200 像素高)被添加到正在访问的当前页面。 Link 1 Link 2 Link 3 L
我在我的一个元素中使用了魔术线。除了一些下拉元素外,它工作得很好。当我单击某些下拉菜单时,它会重置到页面末尾。理想情况下,我希望它保持在父导航之上。 我正在使用 Bootstrap 下拉菜单。 HTM
我试图将带有底部边框的菜单更改为带有底部箭头。 例如:http://i.imgur.com/3onjcjV.png https://css-tricks.com/jquery-magicline-na
这是我曾经写过的代码。如果没有滚动,则它可以正常工作。但是当您单击滚动区域中的其余元素时,将无法正常工作。点击Link4后面的元素即可了解问题。 $(function() { $(".li").c
我使用 jQuery MagicLine 作为垂直滑动。我希望它是这样的,当我点击菜单时,该行将停留在该菜单项上,而不是像往常一样回到第一个菜单项。而且每当点击页面的向下箭头时,magicline 应
我只是试图通过删除我将在下面放置的 CSS 代码来删除内置在我的 Wordpress 主题中的 MagicLine。它起作用了,线路消失了,但现在我的导航全都跳动了,正如您在网站上看到的那样:http
我有 wordpress 网站,主页上有博客文章过滤功能。当您单击其中一个过滤器时 - 帖子会根据所选过滤器的类别发生变化。 我想做的是添加“MagicLine”,就像发布在这个 Fiddle 上的一
我正在尝试使用边框动画(来自 CSSTricks 的 MagicLine),它工作正常但我面临的唯一挑战是,目前它开始第一个元素并为所有元素设置动画,但是如果我点击任何元素然后我从第一项添加相同的类并
我尝试在我的网站上使用 MagicLine jQuery Navigation,但遇到了一个小问题。我希望下划线与当前突出显示的单词一样长。相反,它长了几个像素,我根本无法处理。我试图用 CSS 修复
我一直在尝试删除 CKEditor 中允许您插入段落的红线,但它顽固地拒绝删除自己。 在创建它的 javascript 中添加此代码: CKEDITOR.replace(target,{ re
我正在使用 Flexslider 进行幻灯片放映,我正在尝试使用 Magicline与它。 到目前为止一切正常,但是如果我单击箭头转到下一张幻灯片,magicline 不会移动 - 只有当我将鼠标悬停
有人熟悉 Magic Line jquery 菜单吗? http://css-tricks.com/jquery-magicline-navigation/ 我找不到任何关于如何让它在 Wordpre
第一次发帖。希望大家能帮忙。将不胜感激,我相信我会学到一些东西。此外,如果您在下面看到我的问题之外的任何其他冗余,请随时给我一个关于编码实践的新问题。我需要尽快学习尽可能多的东西。关于问题! 我有两个
我是一名优秀的程序员,十分优秀!