css - 删除图像链接的悬停颜色

标签 css ruby-on-rails ruby-on-rails-4

我正在使用此代码在show View 中显示图像链接:

<%= link_to( image_tag("wikipedia.org.png", {alt: "Wikipedia", size: "24x24"}), @entity.wikipedia_url, {class: "plain", :target => "_blank", :rel=>"nofollow"} ) if @entity.wikipedia_url.present?  %>

当鼠标悬停在图像链接上时,结果如下:

enter image description here

生成的 HTML:

<a class="plain" href="https://en.wikipedia.org/wiki/foobar" rel="nofollow" target="_blank"><img alt="Wikipedia" src="/assets/wikipedia.org.png" height="24" width="24"></a>

我想删除图片链接的悬停颜色,同时保留文本链接的悬停颜色。

因此,我补充说:

a.plain {
  &:hover {
        text-decoration: none;
  }
}

到原来的scaffold.css.scss:

a {
  color: #000;
  &:visited {
    color: #666;
  }
  &:hover {
    color: #fff;
    background-color: #000;
  }
}

这并没有移除悬停颜色。我需要更改什么?

最佳答案

这是我在 CSS 中的做法:

a {color: #000;} 
a:visited {color: #666;} 
// `!important` overwrites whatever you or who else set before for the a element.
a:hover {color: #fff!important; background-color: #000;}

关于css - 删除图像链接的悬停颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25001015/

相关文章:

mysql - ActiveRecord 请求过多

css - 仅在悬停时过渡

css - 应用 :nth-of-type to a pseudoselector rather than a class or element type (without jQuery or even JS)

ruby-on-rails - 使用 PG 进行 ROR

ruby-on-rails - 使用可选参数进行路由

javascript - AMP-HTML页面如何从rails/app/assets/javascript文件夹加载javascript?

javascript - 如何通过 AJAX 使用 Wicked wizard gem?

css - 图像背景作为页面标题,下方带有响应式空白

css - 无法在 Twitter Bootstrap 中格式化列和内容

ruby-on-rails - 在集合和祖 parent 上使用 .where 创建范围