[英]Affect other elements when we hover anything
I have two images, first image is hidden and when we hover second image the first image should be visible. 我有两个图像,第一个图像是隐藏的,当我们将第二个图像悬停时,第一个图像应该是可见的。 The codes and class names are like this :
代码和类名是这样的:
<div class="entrycontent">
<p>
<a>
<img class="alignnone size-full wp-image-48" src="path" />
</a>
<a>
<img class="alignnone size-full wp-image-42" src="path" />
</a>
</p>
</div>
If you are allowed to change the markup, you can use the same parent for both images. 如果允许您更改标记,则可以为两个图像使用相同的父对象。
html: 的HTML:
<div class="entrycontent">
<p>
<a>
<img class="alignnone size-full wp-image-48" src="path" />
<img class="show-on-hover alignnone size-full wp-image-42" src="path" />
</a>
</p>
</div>
css: CSS:
a .show-on-hover {
display: none;
}
a:hover .show-on-hover {
display: block;
}
If you cannot change the markup, you need to use JavaScript. 如果无法更改标记,则需要使用JavaScript。
.wp-image-42:hover +.wp-image-48 { display: block; }
Try this. 尝试这个。 I m not sure about this.
我对此不太确定。 This is my idea only.
这只是我的主意。 I hope it will be work fine.
我希望一切都会好起来的。 All the best for getting result
祝一切顺利
please refer this fiddle for getting clearance 请参考此小提琴以获得许可
You have to change HTML structure to the following: 您必须将HTML结构更改为以下内容:
<div class="entrycontent">
<p>
<a>
<img class="alignnone size-full wp-image-48" src="path" />
<img class="alignnone size-full wp-image-42" src="path" />
</a>
</p>
</div>
And styles: 和样式:
.entrycontent img.wp-image-48
{
display: none;
}
.entrycontent a:hover img.wp-image-48
{
display: block;
}
This must work 这必须工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.