Ver Mensaje Individual
  #5 (permalink)  
Antiguo 11/11/2013, 22:25
Avatar de Faks
Faks
 
Fecha de Ingreso: junio-2012
Mensajes: 26
Antigüedad: 11 años, 10 meses
Puntos: 1
Respuesta: Problema para ubicar navegación postion:absolute

Logre alinear la sub-nav en todos los exploradores. No logre que Firefox me respete el tamaño de la tipografía.
Como por el momento lo considero un problema menor, lo pasare por alto hasta que me de problemas.

La alineación la logre con jQuery sacada de un tutorial que dejo al final de la respuesta.
El código quedo de la siguiente manera (para el que ande con problema similar):

El script
Código Javascript:
Ver original
  1. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
  2.     <script type="text/javascript">
  3.         $(document).ready(function() {
  4.          
  5.          $("ul#top-nav li").hover(function() { //Hover over event on list item
  6.           $(this).css({ 'background' : '#1376c9 url(topnav_active.gif) repeat-x'}); //Add background color and image on hovered list item
  7.           $(this).find("span").show(); //Show the subnav
  8.          } , function() { //on hover out...
  9.           $(this).css({ 'background' : 'none'}); //Ditch the background
  10.           $(this).find("span").hide(); //Hide the subnav
  11.          });
  12.          
  13.         });
  14.     </script>

HTML
Código HTML:
Ver original
  1. <nav id="top-nav">
  2.                 <ul>
  3.                     <li><a href="#" class="active">Noticias</a></li>
  4.                     <li><a href="#">Roster</a>
  5.                         <span>
  6.                             <a href="#">Battlefield</a>
  7.                             <a href="#">Counter Strike</a>
  8.                             <a href="#">Dota</a>
  9.                             <a href="#">Leage of Legends</a>
  10.                             <a href="#">War Thunder</a>
  11.                         </span>
  12.                     </li>
  13.                     <li><a href="#">Cerrados</a>
  14.                         <span>
  15.                             <a href="#">Jugados</a>
  16.                             <a href="#">Proximos</a>
  17.                         </span>
  18.                     </li>
  19.                     <li><a href="#">Torneos</a></li>
  20.                     <li><a href="#">Servidores</a>
  21.                         <span>
  22.                             <a href="#">Team Speak 3</a>
  23.                             <a href="#">Battlefield 4</a>
  24.                         </span>
  25.                     </li>
  26.                     <li><a href="#">Multimedia</a>
  27.                         <span>
  28.                             <a href="#">Fotos</a>
  29.                             <a href="#">Videos</a>
  30.                             <a href="#">Screenshots</a>
  31.                         </span>
  32.                     </li>
  33.                     <li><a href="#">Foro</a></li>
  34.                     <li><a href="#">Contacto</a></li>
  35.                 </ul>
  36.             </nav><!-- fin top-nav -->

CSS
Código CSS:
Ver original
  1. /* NAVEGACION */
  2.  
  3. #top-nav {
  4.     height: 81px;
  5.     width: 100%;
  6.     background: url('../img/nav-bg.png') repeat-x;
  7. }
  8.  
  9. #top-nav ul {
  10.     padding-left: 5px;
  11.     font-size: 0.9em;
  12.     text-transform: uppercase;
  13.     position: relative;
  14. }
  15.  
  16. #top-nav ul li {
  17.     padding: 15px;
  18.     float: left;
  19.     padding-right: 20px;
  20. }
  21.  
  22.     #top-nav ul li a {
  23.         color: #fff;
  24.         font-weight: bold;
  25.         text-decoration: none;
  26.     }
  27.  
  28.     #top-nav ul li a:hover {
  29.         color: #2da7e4;
  30.     }
  31.  
  32. #top-nav li span {
  33.     position: absolute;
  34.     float: left;
  35.     height: 30px;
  36.     padding: 20px 15px 15px 10px;
  37.     margin-top: -10px;
  38.     left: 10px;
  39.     top:45px;
  40.     width: 975px;
  41.     display: none;
  42.     z-index: 100;
  43. }
  44.  
  45.     #top-nav li span a {
  46.         padding-right: 20px;
  47.         font-size: 0.833em;
  48.         color: #666666;
  49.     }
  50.  
  51. #top-nav li:hover span { display: block; }
  52. #top-nav li span a:hover { color: #2da7e4;}

El enlace al tutorial -> http://www.htmldrive.net/items/show/239/Horizontal-Subnav-w-CSS-jQuery.html