I have looked all over for this and I can’t seem to figure it out. I have a list of links that show an image when hovering over each one. I also have a default image in that same place holder when no links are being hovered over. How do I make that default image disappear when the links showing their images. I don’t want to use backgrounds to cover the default image.
https://jsfiddle.net/76tnfh96/2/
HTML:
<div class="links">
<p class="default_img"><a><img src="http://thedeskdoctors.com/Images/LifePreserver.jpg"></a></p>
<ul id="over" class="links">
<li><a>Link 1<span><img src="http://innovativeprofessionaloffices.com/wp-content/uploads/2014/09/IPOLogo.png"></span></a></li>
<li><a>Link 2<span><img src="http://mojosimon.files.wordpress.com/2011/12/large-company.jpg?w=600"></span></a></li>
<li><a>Link 3<span><img src="http://innovativeprofessionaloffices.com/wp-content/uploads/2014/07/seo-for-small-business-300x200.jpg"></span></a></li>
</ul>
</div>
CSS:
<style type="text/css">
.links .default_img a {
top:100px;
float:right;
width:100px;
height:100px;
background:#000000;
position:absolute;
display:none;
}
/*Link position*/
ul.links {
list-style:none;
padding:0;
width:100px;
}
.links li {
width:200px;
color:#000000;
}
/*Hover Image Position/transition out*/
.links li a span, .links li a b {
position:absolute;
right:8px;
top:-999em;
display: none;
}
.links li a:hover span {
top:24px;
display: block;
}
</style>
3
Answers
With jquery:
Just changed a couple of things so you don’t have to use jQuery/javascript. To be able to hover action another non dependent element you would need javascript as that would be called a disjointed rollover.
Changed image sizes just so it would fit in view while testing.
You can leave your whole Markup like what you already had, and add this JavaScript code to your page. You do not need to add any frameworks, and this runs on all browsers.
Example
(The example might lag a bit because your CSS moves your images like wild)
Example 2
(Moved the images for better testing purposes)