Ir para conteúdo
Fórum Script Brasil
  • 0

Ajuda com Menu Pop-up


LucasConstantino

Pergunta

Bom galera, criei um menu seguindo os passos desse tutorial na internet: "CSS Exoress Oure Drop-Down and Popup Menus"

Como meu menu não poderia ser simples como o exemplo nesse mesmo tutorial, eu resolvi tentar modificar um pouco o arquivo ".css" resultante no final do tutorial. O resultado contém também um arquivo javascript, mas como não me arrisquei a editar o javascript e, antes das modificações no ".css" o menu funcionava perfeitamente, então resolvi não colocar na seção Javascript. Bom, ta ai o resultado final que desejado:

esperado.jpg

Cada link do menu principal agora é uma imagem diferente, e no Sub-menu modifiquei o background image (repeat x) por uma imagem, assim como o background rollover image.

Bom, o problema ta ai; essa imagem acima mostra o resultado que eu gostaria de obter... e que obtenho no Firefox... porém, é assim que ele aparece no Internet Explorer 7:

atual.jpg

A imagem acima ocorre quando passo o mouse por cima de qualquer botão do menu. Ele simplesmente cria algo como uma margem acima do menu!

Bom, espero que tenham entendido o problema... agora cá estam os códigos:

Esse primeiro é o arquivo Javascrit (linguagem que por sinal não entendo nada ainda):

/* 
  ------------------------------------
  PVII Menu CSS Express Drop-Down Menu
  by Project Seven Development
  www.projectseven.com
  ------------------------------------
*/
function P7_ExpMenu(){ //v1.1.0.2 by PVII-www.projectseven.com
 if(navigator.appVersion.indexOf("MSIE")==-1){return;}
 var i,k,g,lg,r=/\s*p7hvr/,nn='',c,cs='p7hvr',bv='p7menubar';
 for(i=0;i<10;i++){g=document.getElementById(bv+nn);if(g){
 lg=g.getElementsByTagName("LI");if(lg){for(k=0;k<lg.length;k++){
 lg[k].onmouseover=function(){c=this.className;cl=(c)?c+' '+cs:cs;
 this.className=cl;};lg[k].onmouseout=function(){c=this.className;
 this.className=(c)?c.replace(r,''):'';};}}}nn=i+1;}
}
Me parece um Javacript não muito complicado... porém eu continuo não entendendo nada... Aqui o arquivo ".css":
/* 
  ------------------------------------
  PVII Menu CSS Express Drop-Down Menu
  by Project Seven Development
  www.projectseven.com
  ------------------------------------
*/

/*
p7menubar is the root UL and p7menubar ul applies to all the sub-menu ULs.
We set padding and margin to zero to eliminate all indentation, turn bullets off,
and set a font-family different from the global font-family declared for the
body element above. This sets font for just the menu. Do not add a font-size here.
*/
#p7menubar, #p7menubar ul {
    padding: 0;
    margin: 0;
    list-style: none;
    font-family: Arial, Helvetica, sans-serif;
    background-image: url(../images/principal_buttom.gif);
}
/*
Root-Level Links.  Do not change the first two properties.
Adjust padding values to make the root links taller and to offset them
from the left and right edges of the link box. The border right creates a
separator between links. Font-size is set here and will apply to all menu levels.
Font color is set to light gray.
*/
#p7menubar a {
    display: block;
    text-decoration: none;
    font-size: .85em;
    color: #CCCCCC;
}
/*
Class assigned to those Root-Level links that have associated Sub-Menus.
The top and bottom padding assigned this element must be the same as
that assigned to the p7menubar a element. The right padding is increased
to accomodate the display of background image depicting a downward
pointing arrow.
*/
#p7menubar li {
    float: left;
    width: 9em;
}
/*
Sets width for Sub-Menu box and the List Items inside - in proportional em units. 
This allows the sub-menu width to expand if users resize the text in their browsers.
*/
#p7menubar li ul, #p7menubar ul li  {
    width: 12em;
}
/*
The sub-menu links. We set color and turn off the right border, which
would otherwise be inherited from the root link rule. We set top and 
bottom padding less than the root items and increas the left padding
to indent the sub-menu links a small amount in from the root links.
*/
#p7menubar ul li a  {
    color: #565656;
    border-right: 0;
    padding-right: 12px;
    padding-left: 16px;
    padding-top: 1px;
    padding-bottom: 2px;
}
/*
Sub-Menu Unordered Lists describes each dropdown sub-menu grouping. 
Positioned Absolutely to allow them to appear below their root trigger.
Set to display none to hide them until trigger is moused over.
Background Color must be set or problems will be encountered in MSIE.
Right and bottom borders are set to simulate a raised look.
A gradient background image is assigned.
*/
#p7menubar li ul {
    position: absolute;
    display: none;
    background-color: #FFFFFF;
    border-top: 1px solid #575757;
    border-left: 1px solid #575757;
    border-right: 1px solid #575757;
    background-image: url(images/submenu_bg.jpg);
    background-repeat: repeat;
}
/*
Changes the Text color and background color when the Root-Level
menu items are moused over. The second selector sets color and background
when Root-Level items are accessed with the keyboard tab key. The third
selector sets an active state to support keyboard access in MSIE. The fourth 
selector is assigned to IE5 and IE6 Windows via the P7_ExpMenu script.
Note that IE7 supports hover on elements other than links and so behaves
like Firefox, Opera, and Safari - making the menu operable even if JavaScript
is not enabled.
*/
#p7menubar li:hover a, #p7menubar a:focus,
#p7menubar a:active, #p7menubar li.p7hvr a {
    color: #000000;
}
/*
Set the Sub-Menu UL to be visible when its associated
Root-Level link is moused over. The second selector is 
assigned to IE5 and IE6 via the P7_ExpMenu script.
*/
#p7menubar li:hover ul, #p7menubar li.p7hvr ul {
    display: block;
}
/*
Sets the Text color of the Sub-Level links when the Root-Level
menu items are moused over. The second selector is 
assigned to IE5 and IE6 via the P7_ExpMenu script.
The color set should march the normal Sub-Level link color
in the rule: #p7menubar ul li a. The background color must be
transparent to allow the underlying gradient background on the UL
to show through.
*/
#p7menubar li:hover ul a, #p7menubar li.p7hvr ul a {
    color: #000000;
    background-color: transparent;
    clear: both;
}
/*
The normal hover class for Sub-Level links. The Important directive
is required for older browsers. We set a background color, which shows
over the gradient background. We set text color to white.
*/
#p7menubar ul a:hover {
    background-color: #606060!important;
    color: #FFFFFF!important;
    background-image: url(images/submenu_bg_r.jpg);
}
/* The single backslash \ character inside this comment
causes IE5 Mac to ignore the following rule, which allows other
browsers to render top-level menu items to their natural width.
Do not edit this rule in any way. */
#p7menubar li {
    width: auto;
}
#menuwrapper {
    height: 28px;
    width: 736px;
    margin-top: 0px;
    padding-top: 0px;
}
#menuwrapper #p7menubar #galeria {
    width: 181px;
}
#menuwrapper #p7menubar #principal {
    width: 111px;
}
#menuwrapper #p7menubar #instalacoes {
    width: 136px;
}
#menuwrapper #p7menubar #administracao {
    width: 164px;
}
#menuwrapper #p7menubar #informacoes {
    width: 144px;
}
Esse arquivo ".css" foi onde alterei a maior parte das informações para modificar a aparência do meu menu. E aqui, por fim, es´ta o ".html" (resumido) que contém o menu:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sede Balneária OAB/SC</title>

<!-- abaixo fica o script do menu -->

<link href="p7exp/p7exp.css" rel="stylesheet" type="text/css">
&lt;script type="text/javascript" src="p7exp/p7exp.js"></script>
<!--[if lte IE 7]>
<style>
#menuwrapper, #p7menubar ul a {height: 1%;}
a:active {width: auto;}
</style>
<![endif]-->

<!-- fim do script do menu -->

&lt;script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>

</head>

<body onload="P7_ExpMenu();MM_preloadImages('images/principal_buttom_r.jpg','images/instalacoes_buttom_r.jpg','images/administracao_buttom_r.jpg','images/informacoes_buttom_r.jpg','images/galeria_buttom_r.jpg')">

<div id="page">

<div id="container">

    <div id="toplogo"></div>
    
    <div id="topmenu"> <!-- --------------------AQUI COMEÇA O MENU----------------------- -->
    
      <div id="menuwrapper">
      <ul id="p7menubar">

<li><div id="principal"><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('principal','','images/principal_buttom_r.jpg',1)"><img src="images/principal_buttom.gif" alt="Principal" name="principal" width="111" height="27" border="0" id="principal2" /></a></div>

<ul>
    <li><a href="#">- Página Inicial</a></li>
    <li><a href="#">- Contato</a></li>
    <li><a href="#">- Endereço</a></li>
</ul>
</li>

<li><div id="instalacoes"><a class="trigger" href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Instalacoes','','images/instalacoes_buttom_r.jpg',1)"><img src="images/instalacoes_buttom.jpg" alt="Instalações" name="Instalacoes" width="136" height="27" border="0" id="Instalacoes" /></a></div>
  
<ul>
<li><a href="#">- Piscinas</a></li>
<li><a href="#">- Campos de futebol</a></li>
<li><a href="#">- Restaurante</a></li>
<li><a href="#">- Churrasqueiras</a></li>
<li><a href="#">- Sala de Jogos</a></li>
<li><a href="#">- Parque Infantil</a></li>
</ul>
</li>

<li><div id="administracao"><a class="trigger" href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('administracao','','images/administracao_buttom_r.jpg',1)"><img src="images/administracao_buttom.gif" alt="Administração" name="administracao" width="164" height="27" border="0" id="administracao2" /></a></div>

<ul>
<li><a href="#">- Regimento</a></li>
<li><a href="#">- Regulamento</a></li>
<li><a href="#">- Escolha do Box</a></li>
<li><a href="#">- Nominata</a></li>
<li><a href="#">- Tabela de Preços</a></li>
</ul>
</li>

<li><div id="informacoes"><a class="trigger" href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('informacoes','','images/informacoes_buttom_r.jpg',1)"><img src="images/informacao_buttom.gif" alt="Informações" name="informacoes" width="144" height="27" border="0" id="informacoes2" /></a></div>
<ul>
<li><a href="#">- Comunicados</a></li>
<li><a href="#">- Dicas</a></li>
<li><a href="#">- Curiosidades</a></li>

</ul>
</li>

<li><div id="galeria"><a class="trigger" href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('galeria','','images/galeria_buttom_r.jpg',1)"><img src="images/galeria_buttom.gif" alt="Galeria de Fotos" name="galeria" width="181" height="27" border="0" id="galeria2" /></a></div>


</li>

</ul>

<br class="clearit">

</div>
      
    </div>

<!-- Close div Topmenu -->

</div>

<!-- Close div CONTAINER -->

</div>
<!-- Close div PAGE -->

</body>
</html>

Desculpem se a dúvida não está me posta ou se esqueci de lhes passar algum dado importante... mas é isso ai! Aguardo respostas e as agradeço desde já!

Link para o comentário
Compartilhar em outros sites

6 respostass a esta questão

Posts Recomendados

  • 0
#p7menubar ul li a {

color: #565656;

border-right: 0;

padding-right: 12px;

padding-left: 16px;

padding-top: 1px;

padding-bottom: 2px;

}

#p7menubar li ul {

position: absolute;

display: none;

background-color: #FFFFFF;

border-top: 1px solid #575757;

border-left: 1px solid #575757;

border-right: 1px solid #575757;

background-image: url(images/submenu_bg.jpg);

background-repeat: repeat;

}

Tira essas duas linhas que eu grifei e poste como ficou

e se possivel poste o link do seu exemplo

Link para o comentário
Compartilhar em outros sites

  • 0

Cara, fiz o que você falou ali e pois bem... aquilo ali muda outra coisa sem relevância... muda a borda dos links selecionados... claro que a idéia era mais ou menos por ai, mas eu já tinha tentado antes mesmo...

bom, http://dl.getdropbox.com/u/287795/OAB/index.html é um endereço que contém meu site no dropbox... é MUIIITO lerdo, mas da pra visualizar de boa ;)

obrigado pela ajuda!

Link para o comentário
Compartilhar em outros sites

  • 0

Cara eu tava vendo esse menu não é compatível com o IE7

Então o erro nem é seu :P

Acho que o esquema vai ser usar uns hacks do IE

Aqui você pode pegar uma introduçãozinha: http://dl.getdropbox.com/u/287795/OAB/index.html

No site do maujor tem mais coisa: http://www.maujor.com/tutorial/condcom.php

Da uma pesquisada e qualquer coisa posta ae

Link para o comentário
Compartilhar em outros sites

  • 0

Olá, LucasConstantino, beleza?

olha só nesse menu temos 3 problemas,

1 - Ele não está dentro das recomendações do w3c, pois exitem elemento "block" dentro de elementos "inline":

<ul>
<li>
<div></div> // essa div deve ficar fora da lista!
</li>
</ul>
2 - O JS se tornou muito extenso para faze ralgo que é simples: segue um exemplo:
function abreMenu1(sub1){
    document.getElementById(sub1).style.display = "block";
    }   
   
function fechaMenu1(sub1){
    document.getElementById(sub1).style.display = "none";
    }
3 - No IE6 ele ta quebrando, mais isso é mais facil de resolver: oab_sc.gif diminua em ums 10px de width um dos 2 boxes, com o seguinte hack:
* html body .classe { propriedade: valor; }

vou fazer o seguinte, vou chegar em casa e montar um exemplo pra você de como montar esse menu com menos da metada do código usado, fique atento ao meu blog, a noite vou postar...

Editado por tilowr
Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...