【问题标题】:How to hide / show icon with :hover如何使用 :hover 隐藏/显示图标
【发布时间】:2017-07-10 20:29:00
【问题描述】:

这正是我想要做的

这是我的代码

img.info-societe {
    cursor: pointer;
    display: none;
}
img.info-societe:hover {
    display: inline;
}

为什么它不起作用?最好的解决方案是什么?

【问题讨论】:

  • 请把问题说清楚
  • 你能在 JSFiddle 和 CodePen 中复制吗
  • 你目前的结果怎么样?
  • 当元素不可见时:hover 将如何工作将:hover 提供给父级,然后图标将在:hover 上可见
  • 应该是这样的.parent(class name or id) img.info-societe { cursor: pointer; display: none; }.parent(class name or id):hover img.info-societe { cursor: pointer; display: block; }

标签: css twitter-bootstrap


【解决方案1】:

我认为你需要这样的东西:

tr {
  cursor: pointer;
}

tr img.info-societe {
  display: none;
}

tr:hover img.info-societe {
  display: inline-block;
}

【讨论】:

【解决方案2】:

您应该使用opacity 属性而不是显示。

img.info-societe {
   cursor: pointer;
   opacity: 0;
}
img.info-societe:hover {
   opacity: 1;
}

【讨论】:

  • 如果opacity0,那么用户应该知道element 放在哪里,hover 就变成了visible
  • 这个答案对我来说更好,因为一旦我的图标出现,我的图标左侧的文本(我将其设为可见/不可见)就会被推到左侧。
猜你喜欢
  • 2012-01-21
  • 1970-01-01
  • 2013-02-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多