By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,700 Members | 1,486 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,700 IT Pros & Developers. It's quick & easy.

Hover menu opera bug

100+
P: 103
Hello All

I have a 'flyout' css menu which uses something like this:

Expand|Select|Wrap|Line Numbers
  1. <ul>
  2.   <li><a>head</a><div style="position:absolute;left:-10000;"><ul><li>more</li><li>even more</li></ul></div></li>
  3.   <li><a>head</a><div style="position:absolute;left:-10000;"><ul><li>more</li><li>even more</li></ul></div></li>
  4. </ul>
  5.  
Expand|Select|Wrap|Line Numbers
  1. ul li:hover div {
  2.   left:0;
  3. }
  4.  
So it works nicely in Firefox ;) I have given up with IE and written some javascript. My problem is Opera! I'm testing on Opera 9 and when I hover over the li, the div appears but it isn't left:0 and it is 'broken' up - so bits are visible, bits aren't.

I have other menus on almost identical setups and they work in Opera9. The error consistently appears on the same sections though.

Some things I've thought about:

z-index - well this isn't a problem - fine in FF and other parts of the page
positioning on parent elements - I have looked at this and on changing the li from relative to static, the error is fixed BUT the div is not left:0 it's left:auto.
left:auto - i've tried this but the div ends up in the wrong place

Any other ideas / known bugs. I don't want to marginalise opera users ;)

Thanks in advance

Henry
Mar 20 '08 #1
Share this Question
Share on Google+
2 Replies


drhowarddrfine
Expert 5K+
P: 7,435
They work the same to me in FF and Opera.
Mar 20 '08 #2

P: 63
Hi

Im not sure with Opera but I will try out but adding this code js file and adding in your code will help you for IE6

sfHover = function() {
// Support the standard nav without a class of nav.
var el = document.getElementById("nav");
if(!/\bnav\b/.test(el.className) && el.tagName == "UL")
setHover(el);

// Find all unordered lists.
var ieNavs = document.getElementsByTagName('ul');
for(i=0; i<ieNavs.length; i++) {
var ul = ieNavs[i];
// If they have a class of nav add the menu hover.
if(/\bnav\b/.test(ul.className))
setHover(ul);
}

}

function setHover(nav) {
var ieULs = nav.getElementsByTagName('ul');
if (navigator.appVersion.substr(22,3)!="5.0") {
// IE script to cover <select> elements with <iframe>s
for (j=0; j<ieULs.length; j++) {
var ieMat=document.createElement('iframe');
if(document.location.protocol == "https:")
ieMat.src="//0";
else if(window.opera != "undefined")
ieMat.src="";
else
ieMat.src="javascript:false";
ieMat.scrolling="no";
ieMat.frameBorder="0";
ieMat.style.width=ieULs[j].offsetWidth+"px";
ieMat.style.height=ieULs[j].offsetHeight+"px";
ieMat.style.zIndex="-1";
ieULs[j].insertBefore(ieMat, ieULs[j].childNodes[0]);
ieULs[j].style.zIndex="101";
}
// IE script to change class on mouseover
var ieLIs = nav.getElementsByTagName('li');
for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]) {
// Add a sfhover class to the li.
ieLIs[i].onmouseover=function() {
if(!/\bsfhover\b/.test(this.className))
this.className+=" sfhover";
}
ieLIs[i].onmouseout=function() {
if(!this.contains(event.toElement))
this.className=this.className.replace(' sfhover', '');
}
}
} else {
// IE 5.0 doesn't support iframes so hide the select statements on hover and show on mouse out.
// IE script to change class on mouseover
var ieLIs = document.getElementById('nav').getElementsByTagNam e('li');
for (var i=0; i<ieLIs.length; i++) if (ieLIs[i]) {
ieLIs[i].onmouseover=function() {this.className+=" sfhover";hideSelects();}
ieLIs[i].onmouseout=function() {this.className=this.className.replace(' sfhover', '');showSelects()}
}
}
}

// If IE 5.0 hide and show the select statements.
function hideSelects(){
var oSelects=document.getElementsByTagName("select");
for(var i=0;i<oSelects.length;i++)
oSelects[i].className+=" hide";
}

function showSelects(){
var oSelects=document.getElementsByTagName("select");
for(var i=0;i<oSelects.length;i++)
oSelects[i].className=oSelects[i].className.replace(" hide","");
}

// Run this only for IE.
if (window.attachEvent) window.attachEvent('onload', sfHover);
// end

Other also I will try.
Regards Paulson C Paul.


Hello All

I have a 'flyout' css menu which uses something like this:

Expand|Select|Wrap|Line Numbers
  1. <ul>
  2.   <li><a>head</a><div style="position:absolute;left:-10000;"><ul><li>more</li><li>even more</li></ul></div></li>
  3.   <li><a>head</a><div style="position:absolute;left:-10000;"><ul><li>more</li><li>even more</li></ul></div></li>
  4. </ul>
  5.  
Expand|Select|Wrap|Line Numbers
  1. ul li:hover div {
  2.   left:0;
  3. }
  4.  
So it works nicely in Firefox ;) I have given up with IE and written some javascript. My problem is Opera! I'm testing on Opera 9 and when I hover over the li, the div appears but it isn't left:0 and it is 'broken' up - so bits are visible, bits aren't.

I have other menus on almost identical setups and they work in Opera9. The error consistently appears on the same sections though.

Some things I've thought about:

z-index - well this isn't a problem - fine in FF and other parts of the page
positioning on parent elements - I have looked at this and on changing the li from relative to static, the error is fixed BUT the div is not left:0 it's left:auto.
left:auto - i've tried this but the div ends up in the wrong place

Any other ideas / known bugs. I don't want to marginalise opera users ;)

Thanks in advance

Henry
Apr 1 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.