html - CSS 按钮类断开链接

标签 html css hyperlink

我正在为我正在处理的网站使用 CSS3 按钮。然而,控制这些按钮的 CSS 似乎破坏了它设置样式的链接。如果有人能指出我哪里出错了,将不胜感激。

CSS 控制按钮:

.button {
    display: inline-block;
    zoom: 1; /* zoom and *display = ie7 hack for display:inline-block */
    *display: inline;
    vertical-align: baseline;
    margin: 0 2px;
    outline: none;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    font: 14px/100% Arial, Helvetica, sans-serif;
    padding:5px 15px;
    text-shadow: 0 1px 1px rgba(0,0,0,.3);
    -webkit-border-radius: .5em; 
    -moz-border-radius: .5em;
    border-radius: .5em;
    -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);
    -moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);
    box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.button:hover {
    text-decoration: none;
}
.button:active {
    position: relative;
    top: 1px;
}
.blue {
    color: #d9eef7;
    background: #0095cd;
    background: -webkit-gradient(linear, left top, left bottom, from(#009DD1), to(#009DD1));
    background: -moz-linear-gradient(top,  #009DD1,  #009DD1);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#00adee', endColorstr='#0078a5');
}
.blue:hover {
    background: #007ead;
    background: -webkit-gradient(linear, left top, left bottom, from(#0095cc), to(#00678e));
    background: -moz-linear-gradient(top,  #0095cc,  #00678e);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#0095cc', endColorstr='#00678e');
}
.blue:active {
    color: #FFFFFF;
    background: -webkit-gradient(linear, left top, left bottom, from(#0078a5), to(#00adee));
    background: -moz-linear-gradient(top,  #0078a5,  #00adee);
    filter:  progid:DXImageTransform.Microsoft.gradient(startColorstr='#0078a5', endColorstr='#00adee');
}

以及违规链接:

<div class="nav">
    <a href='http://www.twantrum.com/mild.html' target="_top" class='button blue'>Mild</a>
    <a href='http://www.twantrum.com/restrained.html' target="_top" class='button blue'>Restrained</a>
    <a href='http://www.twantrum.com/angry.html' target="_top" class='button blue'>Angry</a>
    <a href='http://www.twantrum.com/mel-gibson.html' target="_top" class='button blue'>Mel Gibson</a>
</div>

最佳答案

您发布的标记没有错误。

尽管查看您的页面本身,我注意到这部分会产生错误:

<script type="text/javascript">
$(document).ready(function(){
   $('.button').click(function(){ return false; });
});
</script>

这里回答了为什么这不起作用:What's the effect of adding 'return false' to a click event listener?

希望对您有所帮助。

关于html - CSS 按钮类断开链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7994126/

相关文章:

javascript - 如何将robots.txt添加到 Node 应用程序?

jquery - 为什么向左滚动不适用于负值?

jquery - 在同一元素上使用 jQuery 和 CSS 悬停状态

linux - 在scons 'LIBS'命令中使用 'Program'找不到静态库,为什么?

javascript - 带有 Javascript onclick 事件的 HTML anchor 标记

jquery - 从另一个网页上的链接选择 JQUERY 选项卡中的 anchor

html - 如何制作页脚的图像映射

css - 如何修复两个 div 之间的自动边距?

javascript - 使用 jQuery 在淡出( fiddle )之后为 DIV 的重新定位设置动画?

jquery - 在子菜单中保持父悬停状态在导航上