Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

DaNieL^^

CSS Menu Horizontal não funciona no IE

Recommended Posts

Achei na net um exemplo de menu horizontal que funciona perfeitamente no Firefox.

Mas no Internet Explorer não funciona.

Alguém poderia me ajudar a adaptar o codigo para funcionar no IE também?

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br" lang="pt-br">
<head>
<style type="text/css">
	/*** Nav bar styles ***/

ul.nav,
.nav ul{
/*Remove all spacings from the list items*/
	margin: 0;
	padding: 0;
	cursor: default;
	list-style-type: none;
	display: inline;
}

ul.nav{
	display: table;
}
ul.nav>li{
	display: table-cell;
	position: relative;
	padding: 2px 6px;
}

ul.nav li>ul{
/*Make the sub list items invisible*/
	display: none;
	position: absolute;
	max-width: 40ex;
	margin-left: -6px;
	margin-top: 2px;
}

ul.nav li:hover>ul{
/*When hovered, make them appear*/
	display : block;
}

.nav ul li a{
/*Make the hyperlinks as a block element, sort of a hover effect*/
	display: block;
	padding: 2px 10px;
}

/*** Menu colors (customizable) ***/

ul.nav,
.nav ul,
.nav ul li a{
	background-color: #fff;
	color: #369;
}


ul.nav li:hover,
.nav ul li a:hover{
	background-color: #369;
	color: #fff;
}

ul.nav li:active,
.nav ul li a:active{
	background-color: #036;
	color: #fff;
}

ul.nav,
.nav ul{
	border: 1px solid #369;
}

.nav a{
	text-decoration: none;
}
</style>

</head>
<body>
	
	<ul class="nav">
<li><strong>a navigation item</strong>
	<ul>
	<li>a navigation list item</li>
	<li>...</li>
	<li>...</li>
	<li>...</li>
	</ul>
</li>
<li><strong>a navigation item</strong>
	<ul>
	<li>another navigation list item</li>
	<li>...</li>
	<li>...</li>
	<li>...</li>
	</ul>
</li>
<li>...</li>
...
</ul>

</body>
</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Não funciona no IE, pq ele não reconhece o :hover, em nenhuma outra tag, se não o a.

Então é preciso um javascript para fazer isso.

startList = function() {
if (document.all&&document.getElementById) {
	navRoot = document.getElementById("menu");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
					this.className+=" over";
				}
			node.onmouseout=function() {
		this.className=this.className.replace
	(" over", "");
   }
   }
  }
 }
}
window.onload=startList;
Ai você adicionaria a classe "over", no teu css, e no caso desse JS acima, o id do UL do menu seria "menu".

Basta adaptar.

Tem esse aqui horizontal funcionando:

http://forum.imasters.com.br/index.php...t&p=1272083

 

e o do Maujor:

http://maujor.com/tutorial/ddownmenu.php

 

A técnica para desenvolver é a mesma. Dá uma olhada no Maujor, ele explica bem.. se você não conseguir, vai postando teus códigos.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.