css - Chrome 上链接的奇怪悬停行为

标签 css html hyperlink hover sass

我在 Chrome 列表中的链接上遇到奇怪的悬停行为。 我已设法在此 jsFiddle 中重现该问题从网站复制整个 html 和 css。

问题出在侧边菜单的第一个元素上,即其中包含“Maria Montessori”的链接。发生的事情是悬停区域就像在文本所在的中间中断。就像有东西覆盖了按钮的中间部分。亲自尝试一下即可理解我的意思。

相关代码是这样的:

<ul class="page-menu">
    <li class="page_item page-item-30"><a href="http://...">Maria Montessori</a></li>
    <li class="page_item page-item-32"><a href="http://...">La pedagogia scientifica</a></li>
...

还有CSS:

.page-menu {
    display: inline-block;
    margin-right: 25px;
    text-align: center;
    width: 210px;
    li {
        margin-bottom: 10px;
    }
    li.current_page_item {
        a {
            background-color: $blue-montessori;
            border-bottom: 2px solid $blue-montessori;
            color: white;
            font-weight: bold;
        }
    }
    li.current_page_parent {
        a {
            background-color: $blue-montessori;
            border-bottom: 2px solid $blue-montessori;
            color: white;
            font-weight: bold;
        }
    }
    a {
        background-color: $grey-light;
        border-bottom: 2px solid $grey-light;
        color: $grey-dark;
        display: block;
        font-family: Lato;
        font-weight: 300;
        line-height: 1.2;
        padding: 15px 20px;
        text-decoration: none;
        text-transform: uppercase;
        &:hover {
            background-color: $blue-light;
            border-bottom: 2px solid $blue-dark;
            color: white;
            font-weight: 400;
        }
    }
    ul.children {
        margin-top: 10px;
        li {
            margin-bottom: 10px;
            margin-left: 10px;
        }
        li a {
            background-color: #f9f9f9;
            border-bottom: 2px solid #f9f9f9;
            color: $grey-dark;
            display: block;
            font-family: Lato;
            font-size: 12px;
            font-weight: 400;
            line-height: 1.2;
            padding: 10px 20px;
            text-decoration: none;
            text-transform: uppercase;
            &:hover {
                background-color: $blue-light;
                border-bottom: 2px solid $blue-dark;
                color: white;
                font-weight: 400;
            }        
        }

        li.current_page_item {
            a {
                background-color: $blue-montessori;
                border-bottom: 2px solid $blue-montessori;
                color: white;
                font-weight: bold;
            }
        }
    }
    .page_item_has_children > .children {display: none;} /*hides the submenu*/
    .page_item_has_children.current_page_item > .children,
    .page_item_has_children.current_page_ancestor > .children {display: block;} /*shows the submenu for the current page or when on its subpages */
}

用开发人员工具检查它并没有真正帮助,奇怪的是问题似乎只出现在第一个元素上。无论如何,在 Firefox 中工作正常。

最佳答案

由于 div 的行高属性,您的 div menu-menu-1-container 与您的第一个菜单重叠。nav-menu 使用填充

.nav-menu {
padding: 17px; /* remove line-height property */
}  

Updated working Code

关于css - Chrome 上链接的奇怪悬停行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27376839/

相关文章:

html - 部署后不显示操作链接上的 MVC4 图像

html - 如何让背景颜色缩放到窗口大小?

css - div 容器大于内部图像

html - 页 footer 分与使用 CSS 的其他分区部分重合

php - 标题创建的数据库中的双链接

excel - 进入新的私有(private)子目录时生成的超链接消失

css - 如何强制 <li> block 到底部

html - 扩展位置绝对div outside overflow hidden div

jquery - 侧边栏导航

javascript - 使用 JavaScript - 循环遍历每个 <li> 并添加带有链接的图片以转到每个 li 中的新页面