twitter-bootstrap 如何使用 :hover 隐藏/显示图标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29364445/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 22:29:39 来源:igfitidea点击:
How to hide / show icon with :hover
提问by Ahmed Ziani
This is exactly what I want to do

这正是我想要做的

And this is my code
这是我的代码
img.info-societe {
cursor: pointer;
display: none;
}
img.info-societe:hover {
display: inline;
}
Why doesn't it work? What's the best solution?
为什么不起作用?最好的解决办法是什么?
回答by cs.matyi
You should use the opacityproperty instead of display.
您应该使用opacity属性而不是显示。
img.info-societe {
cursor: pointer;
opacity: 0;
}
img.info-societe:hover {
opacity: 1;
}
回答by Zakhar Day
I think you need something like this:
我认为你需要这样的东西:
tr {
cursor: pointer;
}
tr img.info-societe {
display: none;
}
tr:hover img.info-societe {
display: inline-block;
}

