CSS css隐藏按钮直到div悬停

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7550048/
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-08-30 01:44:11  来源:igfitidea点击:

css hide button until div hover

csshide

提问by 422

We want to hide button until we hover over the div layer.

我们想隐藏按钮,直到我们将鼠标悬停在 div 层上。

FIDDLE here > Click to view

在这里小提琴 >点击查看

Essentially, I would like to be able to apply this to other elements also, but this will do for now, any help appreciated

从本质上讲,我也希望能够将其应用于其他元素,但现在就可以了,任何帮助表示赞赏

采纳答案by Annika Backstrom

.resultContainer:hover .viewThisResult { display: block; }

:hoverpseudoselector on the parent. Though it's nice when the code for the question is included in the question, for posterity.

:hover父级上的伪选择器。虽然问题的代码包含在问题中很好,但对于后代来说。

回答by Joseph Silber

Simply use the :hoverpseudo-class on the outer div:

只需:hover在外部 div 上使用伪类:

.resultContainer .viewThisResult {
    display: none;
}
.resultContainer:hover .viewThisResult {
    display: inline;
}

Here's the fiddle: http://jsfiddle.net/dTLaF/1/

这是小提琴:http: //jsfiddle.net/dTLaF/1/