Reputation: 169
I'm having a real problem with IE9, i've written some code with a fellow SO user whom has got me this far but i'm scratching my head on how to so this as my jQuery skills are not to great.
This code work perfectly how I want it to in other browser's but it doesn't work in IE9 the way I would want it to. The reason for asking is that about half of the office are still using IE9 and they are not looking to upgrade.
What is does is when the user hovers over the purple circle a box appears detailing some information and the whole box is link-able to a page in the site. If you move your mouse anywhere around the circle the box doesn't appear, it only appears when the user hovers over the circle, which is what I want. What its doing in IE9 is if you move around the top of the circle the box appears, so in IE9 the box is invisible but its still works if the user mouse is above the button.
To understand my problem better if you view it in any other browser above IE9 you will see that it works fine. Then view it in IE9 and its seems fine until you move your cursor just above one of the circles and the title pops up, because a few circles are close together the titles get very jumpy and most of the time the text dosent match the place.
Now I know IE9 doesn't fully support CSS3 and HTML5 and I believe the problem to be something todo with data-item="" that IE9 partial supports it or something i'm not quite sure.
I shall include the HTML, CSS and jQuery Code and also a JSFiddle, any help would be great.
Heres the JSFiddle
Below is the HTML code:
<div id="col5" class="left">
<h1>Test</h1>
<div class="mapbox"><img src="http://www.clker.com/cliparts/4/f/5/6/1223613091548471395shokunin_United_Kingdom_map.svg.hi.png" style="z-index: 101; border: none" width="672" height="744" usemap="#Map" alt="Map"/>
<a id="a" class="tooltip js-tooltip" href="#" style="top: -315px; left: 270px; border: none; "><span class="tooltip-wrapper" style="z-index: 103; border: none; "><span class="tooltip-text" style="z-index: 103; cursor: pointer; border: none;">11111111</span></span></a>
<a id="b" class="tooltip js-tooltip" href="#" style="top: -150px; left: 365px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">22222222<br /> <span style="color: red;"><strong>N / A</strong></span></span></span></a>
<a id="c" class="tooltip js-tooltip" href="#" style="top: -512px; left: 165px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">33333333</span></span></a>
<a id="d" class="tooltip js-tooltip" href="#" style="top: -512px; left: 80px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">44444444</span></span></a>
<a id="e" class="tooltip js-tooltip" href="#" style="top: -435px; left: 205px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">55555555</span></span></a>
<a id="f" class="tooltip js-tooltip" href="#" style="top: -310px; left: 125px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">66666666</span></span></a>
<a id="g" class="tooltip js-tooltip" href="#" style="top: -335px; left: 170px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">77777777</span></span></a>
<a id="h" class="tooltip js-tooltip" href="#" style="top: -285px; left: 205px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">88888888</span></span></a>
<a id="i" class="tooltip js-tooltip" href="#" style="top: -270px; left: 150px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">99999999</span></span></a>
<a id="j" class="tooltip js-tooltip" href="#" style="top: -235px; left: 120px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">10101010</span></span></a>
<a id="k" class="tooltip js-tooltip" href="#" style="top: -230px; left: 65px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">12121212</span></span></a>
<a id="l" class="tooltip js-tooltip" href="#" style="top: -200px; left: -65px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">13131313</span></span></a>
<a id="m" class="tooltip js-tooltip" href="#" style="top: -145px; left: -45px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">14141414</span></span></a>
<a id="n" class="tooltip js-tooltip" href="#" style="top: -140px; left: -25px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">15151515</span></span></a>
<a id="o" class="tooltip js-tooltip" href="#" style="top: -160px; left: 10px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">16161616</span></span></a>
<a id="p" class="tooltip js-tooltip" href="#" style="top: -185px; left: 90px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">17171717</span></span></a>
<a id="q" class="tooltip js-tooltip" href="#" style="top: -75px; left: -155px;"><span class="tooltip-wrapper" style="z-index: 103;"><span class="tooltip-text" style="z-index: 103; cursor: pointer;">18181818</span></span></a>
</div>
</div>
<!-- COL.1 END --><!-- COL.2 END -->
<div id="col3" class="right">
<h2>Sidebar<img src="#" width="21" height="18" alt="icon" /></h2>
<div class="box">
<h3>Sidebar</h3>
<ul id="locationList">
<li><a data-item="a" href="#">11111111</a></li>
<li><a data-item="b" href="#">22222222</a></li>
<li><a data-item="c" href="#">33333333</a></li>
<li><a data-item="d" href="#">44444444</a></li>
<li><a data-item="e" href="#">55555555</a></li>
<li><a data-item="f" href="#">66666666</a></li>
<li><a data-item="g" href="#">77777777</a></li>
<li><a data-item="h" href="#">88888888</a></li>
<li><a data-item="i" href="#">99999999</a></li>
<li><a data-item="j" href="#">10101010</a></li>
<li><a data-item="k" href="#">12121212</a></li>
<li><a data-item="l" href="#">13131313</a></li>
<li><a data-item="m" href="#">14141414</a></li>
<li><a data-item="n" href="#">15151515</a></li>
<li><a data-item="o" href="#">16161616</a></li>
<li><a data-item="p" href="#">17171717</a></li>
<li><a data-item="q" href="#">18181818</a></li>
<div class="clear"></div>
</ul>
</div>
Below is the CSS Code:
.tooltip {
position: relative;
display: inline-block;
height: 18px;
width: 18px;
line-height: 26px;
padding: 0 0;
border-radius: 15px;
font-size: 12px;
font-weight: bold;
color: #FFF;
background: #b71a71;
box-shadow: none;
white-space: nowrap;
cursor: pointer;
top: 100px; left: 300px;
}
.tooltip.current {
background: #b1d12d;
}
.tooltip:hover {
background: #b1d12d;
}
.tooltip-wrapper {
pointer-events: none;
position: absolute;
width: 250px;
margin-left: -125px;
left: 50%;
bottom: 100%;
margin-bottom: 5px;
text-align: center;
text-decoration: none;
opacity: 0;
transition: opacity 0.5s ease;
}
.js-tooltip-active .tooltip-wrapper,
.tooltip:hover .tooltip-wrapper,
.tooltip-wrapper:hover {
pointer-events: auto;
opacity: 1;
}
.tooltip-wrapper:after {
z-index: 11;
display: block;
position: absolute;
left: 50%;
margin-left: -7px;
content: " ";
width: 0;
height: 0;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-top: 7px solid #333;
}
.tooltip-wrapper:before {
bottom: -9px;
display: block;
position: absolute;
left: 50%;
margin-left: -8px;
content: " ";
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 8px solid rgba(255,255,255,0.1);
}
.tooltip-text {
display: inline-block;
position: relative;
padding: 6px 9px;
z-index: 10;
white-space: normal;
font-size: 12px;
font-weight: normal;
line-height: 18px;
background: #333;
background: rgba(0,0,0,0.8);
color: #fff;
border-radius: 5px;
text-shadow: none;
cursor: default;
box-shadow: 0 0 rgba(255,255,255,0.1);
}
#locationList li a.active {
color:#b71a71;
}
Below is the jQuery Code:
$(document).ready(function() {
$('.js-tooltip').on('click', function () {
$(this).toggleClass('js-tooltip-active');
});
$('.tooltip').hover(function() {
$('a[data-item="'+this.id+'"]').toggleClass('active');
});
$('#locationList a').hover(function() {
$('#' + $(this).data('item')).toggleClass('js-tooltip-active');
$('#' + $(this).data('item')).toggleClass('current');
});
});
Thanks.
Upvotes: 0
Views: 243
Reputation: 28
It appears that your problem is coming from hiding the tooltip using
.tooltip-wrapper {
...
opacity: 0;
}
The element still occupies space even though you cannot see it. If you hide the element using something like
.tooltip-wrapper {
...
display: none;
}
and then show the element again from the selector you have below it using
.js-tooltip-active .tooltip-wrapper,
.tooltip:hover .tooltip-wrapper,
.tooltip-wrapper:hover {
...
display: block;
}
you eliminate the unexpected results you are experiencing in IE 9. This will eliminate your fade-in effect so you might want to conditionally apply this rule just to IE9 since it appears to be working in the other browsers you are testing. Consider using an existing library for your tooltips such as TipTip which I believe allows sticky tooltips like the ones you are trying to implement.
Edit: I forgot to mention, another source of your problems is possibly the use of the pointer-events
CSS rule, which is not supported by IE 9.
Edit: jsfiddle
Upvotes: 1