[英]Hovering on element and making another element appear at the same time
I've been trying to figure this out for a long time and I can't seem to get it. 我已经尝试解决了很长时间,但似乎无法理解。 I have the following HTML:
我有以下HTML:
<div class="b">
<button>Show when I hover</button>
</div>
<div class="A">When I hover over this the background should change</div>
with the corresponding CSS: 与相应的CSS:
.b {
float: right;
display: none;
}
.A {
float: left;
display: inline;
width: 1000px;
}
.A:hover {
background: gray;
}
.A:hover + .b {
display: block;
}
What I'm trying to do is whenever I hover over A
the b
div and corresponding button should show. 我想做的是每当我将鼠标悬停在
A
, b
div和相应的按钮应该显示。 In addition, I want it such that when my mouse is on the button, the background of A
is still gray as if I was hovering over it. 另外,我希望它使鼠标在按钮上时,
A
的背景仍然是灰色的,就像我将鼠标悬停在它上面一样。 I can't seem to figure this out. 我似乎无法弄清楚。 Any ideas?
有任何想法吗?
Relevant JSFiddle: http://jsfiddle.net/sn19k1wz/3/ 相关的JSFiddle: http : //jsfiddle.net/sn19k1wz/3/
You can do this by changing position of A
and B
您可以通过更改
A
和B
位置来做到这一点
<div class="A">When I hover over this the background should change</div>
<div class="b">
<button>Show when I hover</button>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.