【问题标题】:CSS border-bottom and background on hoverCSS边框底部和悬停背景
【发布时间】:2020-01-09 22:28:23
【问题描述】:

我需要在鼠标悬停时显示底部边框。

另外我需要同时显示背景颜色。

现在,我几乎拥有它!如果你看到这个例子,你会看到悬停在跨度上会给出下划线。但是我需要在进入超链接区域的时候显示下划线。

a{
text-decoration: none;
padding: 25px;

}

a:hover{
color: white;
background: blue;
}

span:hover{
border-bottom: 2px solid red;
}
<a href="#"><span>Combo</span></a>

【问题讨论】:

标签: html hover border underline


【解决方案1】:

试试这个:

a{
text-decoration: none;
padding: 25px;

}

a:hover{
color: white;
background: blue;
}

a:hover{
border-bottom: 2px solid red;
}


<a href="#"><span>Combo</span></a>

【讨论】:

    【解决方案2】:

    这对你有用。

    CSS

    a {
        text-decoration: none;
        padding: 25px;
    
    }
    
    a:hover {
        color: white;
        background: blue;
        border-bottom: 2px solid red;
    }
    

    HTML

    <a href="#"><span>Combo</span></a>
    

    【讨论】:

    • 感谢您的回答。不幸的是,这并不是我想要做的。我需要下划线出现在文本下方(所以它看起来像一个超链接)
    • 也许这在 CSS 中是不可能的? - 我认为我们需要使用 JS
    猜你喜欢
    • 2015-07-03
    • 2015-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-15
    • 1970-01-01
    • 1970-01-01
    • 2015-04-21
    相关资源
    最近更新 更多