如何更改一个元素,而将鼠标悬停在另一个元素上 [英] How to change one element while hovering over another
问题描述
我已经看过几个其他问题,但我似乎没有想到任何他们出来,所以这里是我的问题,我想有一个div或跨度,当你悬停在一个区域会出现,将是像下拉一样。
I have looked at several other questions but I cant seem to figure any of them out, so here is my problem, i would like to have a div or a span, when you hover over it an area would appear and would be like a drop down.
例如我有一个div,我想将鼠标悬停在它上面,并显示我悬停的项目的一些信息。
Such as I have an div, and I want to hover over it and have it show some info about the item I hovered over
<html>
<head>
<title>Question1</title>
<styles type="css/text">
#cheetah {
background-color: red;
color: yellow;
text-align: center;
}
a {
color: blue;
}
#hidden {
background-color: black;
}
a:hover > #hidden {
background-color: orange;
color: orange;
}
</styles>
</head>
<body>
<div id="cheetah">
<p><a href="#">Cheetah</a></p>
</div>
<div id="hidden">
<p>A cheetah is a land mammal that can run up 2 60mph!!!</p>
</div>
</body>
</html>
但这^似乎不工作,我不知道为什么...如果有一种方式
But this ^ doesnt seem to work, I dont know why... and if there is a way to do that in css, I would like to know, but I want any and all suggestions.
推荐答案
你可以在css中做到这一点,仅当隐藏的div是您用于悬停的元素的子元素时,才会显示CSS:
You can achieve this in CSS only if the hidden div is a child of the element you use for hovering:
这篇关于如何更改一个元素,而将鼠标悬停在另一个元素上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!