【问题标题】:How to get a hover effect for glyphicon icons?如何获得字形图标的悬停效果?
【发布时间】:2015-10-26 23:42:31
【问题描述】:

每次我将鼠标悬停在它上面时,我都会尝试让 glyphicon 图标出现。我正在使用<span> 标签。但这拒绝工作。我做错了什么?

application.scss

 /*
 *= require bootstrap3-editable/bootstrap-editable
 *= require bootstrap-datepicker3
 *= require_tree .
 */

  @import "bootstrap-sprockets";
  @import "bootstrap";

.hovering:before {
display: none;
}

.hovering:hover:before {
display: block;
}

在我的 view 文件中,它看起来像这样:

  <span class='hovering'>
    <%= link_to user_task_path(current_user, task.id), method: :delete,
    data: { confirm: 'Are you sure?' }, remote: true do %>
      <i class="glyphicon glyphicon-trash"></i>
    <% end %>
  </span>

【问题讨论】:

    标签: javascript jquery html css css-content


    【解决方案1】:

    Glyphicon 图标不是 .hovering 元素上的伪元素,它是其中包含的 i 元素上的伪元素。因此,我们还需要定位 i 元素:

    .hovering i::before {
        display: none;
    }
    
    .hovering:hover i::before {
        display: block;
    }
    

    【讨论】:

      猜你喜欢
      • 2015-06-19
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      • 2012-04-27
      • 2017-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多