HTML UL LI a href 链接不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26953034/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML UL LI a href links not working
提问by Benjamin Porter
I am working on a website and for the menu I have the following code:
我在一个网站上工作,对于菜单,我有以下代码:
<header>
<div class="sticky-nav">
<a id="mobile-nav" class="menu-nav" href="#menu-nav"></a>
<nav id="menu">
<ul id="menu-nav">
<li><a href="http://aevidum.com">Home</a>
</li>
<li><a href="">Clubs</a>
</li>
<li><a href="">Campaigns</a>
</li>
<li><a href="">Movement</a>
</li>
<li><a href="">Events</a>
</li>
<li><a href="">The Talk</a>
</li>
<li><a href="">Resources</a>
</li>
<li><a href="">Donate</a>
</li>
<li><a href="">#Aevidum</a>
</li>
<li><a href="">Contact</a>
</li>
</ul>
</nav>
</div>
</header>
But when I click on the home link it doesn't go anywhere or do anything. Anyone know what the issue could be?
但是当我点击主页链接时,它不会去任何地方或做任何事情。有谁知道可能是什么问题?
Here is a link to the directory I'm working on it in: http://aevidum.com/brushed/
这是我正在处理的目录的链接:http: //avidum.com/brushed/
回答by Sunil Goli
I think some java-script or jquery function is overriding your current functionality, because the code which you posted works fine without any includes.
我认为某些 java-script 或 jquery 函数正在覆盖您当前的功能,因为您发布的代码在没有任何包含的情况下运行良好。
<header>
<div class="sticky-nav">
<a id="mobile-nav" class="menu-nav" href="#menu-nav"></a>
<nav id="menu">
<ul id="menu-nav">
<li><a href="http://aevidum.com">Home</a>
</li>
<li><a href="">Clubs</a>
</li>
<li><a href="">Campaigns</a>
</li>
<li><a href="">Movement</a>
</li>
<li><a href="">Events</a>
</li>
<li><a href="">The Talk</a>
</li>
<li><a href="">Resources</a>
</li>
<li><a href="">Donate</a>
</li>
<li><a href="">#Aevidum</a>
</li>
<li><a href="">Contact</a>
</li>
</ul>
</nav>
</div>
</header>
回答by vr_driver
I guess you may be using the Brushed Template by Alessio Atzeni?
我猜您可能正在使用 Alessio Atzeni 的拉丝模板?
I had the same problem. Below is the full nav section I have, and where I added a class 'linkfix_LogIn' to the link I needed to be not a relative anchor.
我有同样的问题。下面是我拥有的完整导航部分,我在其中添加了一个类“linkfix_LogIn”到我需要不是相对锚点的链接。
<header>
<div class="sticky-nav">
<a id="mobile-nav" class="menu-nav" href="#menu-nav"></a>
<div id="logo">
<a id="goUp" href="#home-slider" title="Home">Home</a>
</div>
<nav id="menu">
<ul id="menu-nav">
<li class="current"><a href="#home-slider">Home</a></li>
<li><a href="#about">What Is This</a></li>
<li><a href="#contact">Contact</a></li>
<li class="linkfix_LogIn"><a href="http://www.YourURL.com">Outside Link</a></li>
</ul>
</nav>
</div>
</header>
Also in the main.js file, amend the following inside this function:
同样在 main.js 文件中,修改此函数内的以下内容:
BRUSHED.listenerMenu = function(){
And add this little method at the bottom:
并在底部添加这个小方法:
// Fix outside links.
$('.linkfix_LogIn a').on('click',function() {
window.location.href = "http://www.YourURL.com"; // Change This
});
回答by diceworks
If you use "Brushed Template by Alessio Atzeni", It seems to be caused by "plugin.js".
如果你使用“Brushed Template by Alessio Atzeni”,它似乎是由“plugin.js”引起的。
Get "jquery.nav.js" from the following page. https://github.com/davist11/jQuery-One-Page-Nav
从以下页面获取“jquery.nav.js”。 https://github.com/davist11/jQuery-One-Page-Nav
Then overwrite the code of "jQuery One Page Nav Plugin" in the last part of "plugin.js" (near the 30th line to the end) with the contents of "jquery.nav.js".
然后用“jquery.nav.js”的内容覆盖“plugin.js”最后一部分(接近第30行到末尾)的“jQuery One Page Nav Plugin”代码。
I was able to solve the same problem in this way. I hope this helps someone.
我能够以这种方式解决同样的问题。我希望这可以帮助别人。
回答by Nikz
Issue might be with the jquery come with your template. If nothing worked out use a javascript onclick function on the 'href' tag to redirect
问题可能与您的模板附带的 jquery 有关。如果没有任何结果,请在“href”标签上使用 javascript onclick 函数进行重定向
onclick="window.open('https://www.yoursite.com/mypage')"
If you want to mention the target type use this instead
如果您想提及目标类型,请改用它
onclick="window.open('https://www.yoursite.com/mypage', '_blank')"
回答by Kapilnemo
I had the same problem. I just added diplay: block
on the a tag. It's worked for me!
我有同样的问题。我刚刚添加diplay: block
了 a 标签。它对我有用!
ul li a {
display: block;
}