【问题标题】:CSS: Can't get :hover to work, what am I missing?CSS:无法 :hover 工作,我错过了什么?
【发布时间】:2017-06-02 12:53:20
【问题描述】:

下面是我的代码。当我将鼠标悬停在搜索按钮上时,我将获得文本更改效果。我保持按钮背景相同,只是在悬停时尝试更改文本的颜色。我不确定我错过了什么。有没有更简单的方法来实现这一点?该按钮仅保持悬停前的颜色。我没有想法。

.header_search #search-submit {
    width: 80px;
    height: 35px;
    margin: 0 -83px 0 0;
    background: #ff9105; 
    border: 2px solid black; 
    border-left: none; 
    font-size: 14px; 
    color: #008b95;
    -webkit-border-radius: 0 5px 5px 0;
            border-radius: 0 5px 5px 0;
}

    {{ trans_fast }}

.header_search #search-submit:hover {
    background: #ff9105; 
    color: white
}

【问题讨论】:

  • 您的 CSS 语法不正确。缺少分号和{{ trans_fast }} 是什么?

标签: html css


【解决方案1】:
.header_search #search-submit {
   width: 80px;
   height: 35px;
   margin: 0 -83px 0 0;
   background: #ff9105;
   border: 2px solid black;
   border-left: none;
   font-size: 14px;
   color: #008b95;
   -webkit-border-radius: 0 5px 5px 0;
   border-radius: 0 5px 5px 0;
}

/* dont know about this "{{ trans_fast }}" */

.header_search #search-submit:hover {
    background: #ff9105;
    color: white;
}

在这里编辑后,应该看起来不错,trans_fast 对我来说是一个非常陌生的概念。您的一些 css 属性是垂直的,有些是水平的。出于语法目的,请尝试其中一种,但不要同时尝试两种。 PLUS(你忘记了颜色的分号)

【讨论】:

  • 如果 trans_fast 有用的话,把注释和单词拿出来使用,我这样做只是因为我担心这会是个问题。
【解决方案2】:

添加;color: white的结尾

.header_search #search-submit:hover {
    background: #ff9105; 
    color: white;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-09-14
    • 1970-01-01
    • 1970-01-01
    • 2021-08-05
    • 2021-04-05
    • 2012-09-21
    • 2020-07-19
    • 1970-01-01
    相关资源
    最近更新 更多