Foros del Web » Programando para Internet » Javascript »

Menu Desplegable hacia abajo con js

Estas en el tema de Menu Desplegable hacia abajo con js en el foro de Javascript en Foros del Web. buenas amigos, la verdad se 0 de javascript, pero indagando en el tema, he pillado un código muy bueno para un menú desplegable,el efecto que ...
  #1 (permalink)  
Antiguo 30/05/2012, 04:35
Avatar de 60NZ4  
Fecha de Ingreso: mayo-2012
Ubicación: 404 Not found
Mensajes: 112
Antigüedad: 11 años, 11 meses
Puntos: 2
Menu Desplegable hacia abajo con js

buenas amigos, la verdad se 0 de javascript, pero indagando en el tema, he pillado un código muy bueno para un menú desplegable,el efecto que quiero conseguir es muy similar al que hay en el meno de inicio en esta pagina por ejemplo, bueno el caso es que el código que me he descargado, me pone el menú hacia la derecha,yo quiero que se despliegue hacia abajo, aqui os dejo el codigo, porfavor decirme donde debo retocar para desplegar hacia abajo, no tengo tiempo ahora para aprender javascript jeje, aunque lo tengo en mis futuros plantes =)

Aqui el codigo, tal cual
Código Javascript:
Ver original
  1. /************************************************************************************************************
  2.     (C) www.dhtmlgoodies.com, November 2005
  3.    
  4.     This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.  
  5.    
  6.     Terms of use:
  7.     You are free to use this script as long as the copyright message is kept intact. However, you may not
  8.     redistribute, sell or repost it without our permission.
  9.    
  10.     Thank you!
  11.    
  12.     www.dhtmlgoodies.com
  13.     Alf Magne Kalleland
  14.    
  15.     ************************************************************************************************************/
  16.  
  17.     var timeBeforeAutoHide = 700;   // Microseconds to wait before auto hiding menu(1000 = 1 second)
  18.     var slideSpeed_out = 10;    // Steps to move sub menu at a time ( higher = faster)
  19.     var slideSpeed_in = 10;
  20.        
  21.    
  22.     var slideTimeout_out = 25;  // Microseconds between slide steps ( lower = faster)
  23.     var slideTimeout_in = 10;   // Microseconds between slide steps ( lower = faster)
  24.    
  25.     var showSubOnMouseOver = true;  // false = show sub menu on click, true = show sub menu on mouse over
  26.     var fixedSubMenuWidth = false;  // Width of sub menu items - A number(width in pixels) or false when width should be dynamic
  27.    
  28.     var xOffsetSubMenu = 0;     // Offset x-position of sub menu items - use negative value if you want the sub menu to overlap main menu
  29.    
  30.     var slideDirection = 'right';   // Slide to left or right ?
  31.    
  32.     /* Don't change anything below here */
  33.    
  34.     var activeSubMenuId = false;
  35.     var activeMainMenuItem = false;
  36.     var currentZIndex = 1000;      
  37.     var autoHideTimer = 0;
  38.     var submenuObjArray = new Array();
  39.     var okToSlideInSub = new Array();
  40.     var subPositioned = new Array();
  41.    
  42.  
  43.     function stopAutoHide()
  44.     {
  45.         autoHideTimer = -1;
  46.     }
  47.    
  48.     function initAutoHide()
  49.     {
  50.         autoHideTimer = 0;
  51.         if(autoHideTimer>=0)autoHide();
  52.     }
  53.    
  54.     function autoHide()
  55.     {
  56.        
  57.         if(autoHideTimer>timeBeforeAutoHide)
  58.         {
  59.            
  60.             if(activeMainMenuItem){
  61.                 activeMainMenuItem.className='';
  62.                 activeMainMenuItem = false;
  63.             }
  64.            
  65.             if(activeSubMenuId){
  66.                 var obj = document.getElementById('subMenuDiv' + activeSubMenuId);
  67.                 showSub();
  68.             }
  69.         }else{
  70.             if(autoHideTimer>=0){
  71.                 autoHideTimer+=50;
  72.                 setTimeout('autoHide()',50);
  73.             }
  74.         }
  75.     }  
  76.    
  77.     function getTopPos(inputObj)
  78.     {      
  79.       var returnValue = inputObj.offsetTop;
  80.       while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetTop;
  81.       return returnValue;
  82.     }
  83.    
  84.     function getLeftPos(inputObj)
  85.     {
  86.       var returnValue = inputObj.offsetLeft;
  87.       while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;
  88.       return returnValue;
  89.     }
  90.    
  91.     function showSub()
  92.     {
  93.         var subObj = false;
  94.         if(this && this.tagName){
  95.             var numericId = this.parentNode.id.replace(/[^0-9]/g,'');
  96.             okToSlideInSub[numericId] = false;
  97.             var subObj = document.getElementById('subMenuDiv' + numericId);
  98.             if(activeMainMenuItem)activeMainMenuItem.className='';
  99.             if(subObj){
  100.                 if(!subPositioned[numericId]){
  101.                     if(slideDirection=='right'){
  102.                         subObj.style.left = getLeftPos(submenuObjArray[numericId]['parentDiv']) + submenuObjArray[numericId]['parentDiv'].offsetWidth + xOffsetSubMenu + 'px';
  103.                     }else{
  104.                         subObj.style.left = getLeftPos(submenuObjArray[numericId]['parentDiv']) + xOffsetSubMenu + 'px';
  105.                        
  106.                     }
  107.                     submenuObjArray[numericId]['left'] = subObj.style.left.replace(/[^0-9]/g,'');
  108.                     subObj.style.top = getTopPos(submenuObjArray[numericId]['parentDiv']) + 'px';
  109.                     subPositioned[numericId] = true;
  110.                 }              
  111.                 subObj.style.visibility = 'visible';
  112.                 subObj.style.zIndex = currentZIndex;
  113.                 currentZIndex++;   
  114.                 this.className='activeMainMenuItem';
  115.                 activeMainMenuItem = this;
  116.             }
  117.         }else{
  118.             var numericId = activeSubMenuId;
  119.         }
  120.         if(activeSubMenuId && (numericId!=activeSubMenuId || !subObj))slideMenu(activeSubMenuId,(slideSpeed_in*-1));
  121.         if(numericId!=activeSubMenuId && this && subObj){
  122.             subObj.style.width = '0px';
  123.             slideMenu(numericId,slideSpeed_out);
  124.             activeSubMenuId = numericId;
  125.         }else{
  126.             if(numericId!=activeSubMenuId)activeSubMenuId = false;
  127.         }
  128.         if(showSubOnMouseOver)stopAutoHide();
  129.     }
  130.    
  131.     function slideMenu(menuIndex,speed){
  132.         var obj = submenuObjArray[menuIndex]['divObj'];
  133.         var obj2 = submenuObjArray[menuIndex]['ulObj'];
  134.         var width = obj.offsetWidth + speed;
  135.         if(speed<0){
  136.             if(width<0)width = 0;
  137.             obj.style.width = width + 'px';
  138.             if(slideDirection=='left'){
  139.                 obj.style.left = submenuObjArray[menuIndex]['left'] - width + 'px';
  140.                 obj2.style.left = '0px';
  141.             }else{
  142.                 obj2.style.left = width - submenuObjArray[menuIndex]['width'] + 'px'
  143.             }
  144.             if(width>0 && okToSlideInSub[menuIndex])setTimeout('slideMenu(' + menuIndex + ',' + speed + ')',slideTimeout_in); else{
  145.                 obj.style.visibility = 'hidden';
  146.                 obj.style.width = '0px';
  147.                 if(activeSubMenuId==menuIndex)activeSubMenuId=false;
  148.             }
  149.            
  150.         }else{
  151.             if(width>submenuObjArray[menuIndex]['width'])width = submenuObjArray[menuIndex]['width'];
  152.             if(slideDirection=='left'){
  153.                 obj.style.left = submenuObjArray[menuIndex]['left'] - width + 'px';
  154.                 obj2.style.left = '0px';
  155.             }else{
  156.                 obj2.style.left = width - submenuObjArray[menuIndex]['width'] + 'px'
  157.             }      
  158.            
  159.             obj.style.width = width + 'px';
  160.             if(width<submenuObjArray[menuIndex]['width']){
  161.                 setTimeout('slideMenu(' + menuIndex + ',' + speed + ')',slideTimeout_out);
  162.             }else{
  163.                 okToSlideInSub[menuIndex] = true;
  164.             }
  165.         }
  166.     }
  167.     function resetPosition()
  168.     {
  169.         subPositioned.length = 0;
  170.     }
  171.            
  172.     function initLeftMenu()
  173.     {
  174.         var menuObj = document.getElementById('dhtmlgoodies_menu');
  175.         var mainMenuItemArray = new Array();
  176.        
  177.         var mainMenuItem = menuObj.getElementsByTagName('LI')[0];
  178.         while(mainMenuItem){
  179.             if(mainMenuItem.tagName && mainMenuItem.tagName.toLowerCase()=='li'){
  180.                 mainMenuItemArray[mainMenuItemArray.length] = mainMenuItem;
  181.                 var aTag = mainMenuItem.getElementsByTagName('A')[0];
  182.                 if(showSubOnMouseOver)
  183.                     aTag.onmouseover = showSub;
  184.                 else
  185.                     aTag.onclick = showSub;
  186.             }
  187.             mainMenuItem = mainMenuItem.nextSibling;
  188.         }      
  189.        
  190.         var lis = menuObj.getElementsByTagName('A');
  191.         for(var no=0;no<lis.length;no++){
  192.             if(!showSubOnMouseOver)lis[no].onmouseover = stopAutoHide;
  193.             lis[no].onmouseout = initAutoHide;
  194.             lis[no].onmousemove = stopAutoHide;
  195.         }
  196.                
  197.         for(var no=0;no<mainMenuItemArray.length;no++){
  198.             var sub = mainMenuItemArray[no].getElementsByTagName('UL')[0];
  199.             if(sub){
  200.                 mainMenuItemArray[no].id = 'mainMenuItem' + (no+1);
  201.                 var div = document.createElement('DIV');
  202.                 div.className='dhtmlgoodies_subMenu';
  203.                 document.body.appendChild(div);
  204.                 div.appendChild(sub);
  205.                 if(slideDirection=='right'){
  206.                     div.style.left = getLeftPos(mainMenuItemArray[no]) + mainMenuItemArray[no].offsetWidth + xOffsetSubMenu + 'px';
  207.                 }else{
  208.                     div.style.left = getLeftPos(mainMenuItemArray[no]) + xOffsetSubMenu + 'px';
  209.                 }
  210.                 div.style.top = getTopPos(mainMenuItemArray[no]) + 'px';
  211.                 div.id = 'subMenuDiv' + (no+1);
  212.                 sub.id = 'submenuUl' + (no+1);
  213.                 sub.style.position = 'relative';   
  214.  
  215.                 if(navigator.userAgent.indexOf('Opera')>=0){
  216.                     submenuObjArray[no+1] = new Array();
  217.                     submenuObjArray[no+1]['parentDiv'] = mainMenuItemArray[no];
  218.                     submenuObjArray[no+1]['divObj'] = div;
  219.                     submenuObjArray[no+1]['ulObj'] = sub;
  220.                     submenuObjArray[no+1]['width'] = sub.offsetWidth;
  221.                     submenuObjArray[no+1]['left'] = div.style.left.replace(/[^0-9]/g,'');
  222.                 }
  223.                 sub.style.left = 1 - sub.offsetWidth + 'px';   
  224.                
  225.                 // if(document.all)div.style.width = '1px';
  226.                    
  227.                 if(navigator.userAgent.indexOf('Opera')<0){
  228.                     submenuObjArray[no+1] = new Array();
  229.                     submenuObjArray[no+1]['parentDiv'] = mainMenuItemArray[no];
  230.                     submenuObjArray[no+1]['divObj'] = div;
  231.                     submenuObjArray[no+1]['ulObj'] = sub;
  232.                     submenuObjArray[no+1]['width'] = sub.offsetWidth;
  233.                    
  234.                    
  235.                    
  236.                     submenuObjArray[no+1]['left'] = div.style.left.replace(/[^0-9]/g,'');
  237.                     if(fixedSubMenuWidth)submenuObjArray[no+1]['width'] = fixedSubMenuWidth;
  238.                 }  
  239.  
  240.                 if(!document.all)div.style.width = '1px';          
  241.                    
  242.             }          
  243.         }
  244.            
  245.  
  246.        
  247.        
  248.         menuObj.style.visibility = 'visible';
  249.        
  250.         window.onresize = resetPosition;
  251.     }
  252.    
  253.    
  254.     window.onload = initLeftMenu;

¿que debo retocar para que el menu se despliegue hacia abajo en lugar de hacia la derecha?
__________________
Nadie nace aprendido, un experto es simplemente alguien que ya ha cometido muchos errores
  #2 (permalink)  
Antiguo 30/05/2012, 08:57
 
Fecha de Ingreso: mayo-2012
Ubicación: En la Tierra
Mensajes: 41
Antigüedad: 11 años, 10 meses
Puntos: 3
Respuesta: Menu Desplegable hacia abajo con js

Solo copialo, pegalo y agrega el link de jquery.

Aqui estan codigos jquery, en la siguiente respuesta codigo html5 y en la ultima codigo css.


<script type="text/javascript" src="js/jquery-1.2.6.min.js"></script>
<script type="text/javascript">
(function($){
/* hoverIntent by Brian Cherne */
$.fn.hoverIntent = function(f,g) {
// default configuration options
var cfg = {
sensitivity: 7,
interval: 100,
timeout: 0
};
// override configuration options with user supplied object
cfg = $.extend(cfg, g ? { over: f, out: g } : f );
// instantiate variables
// cX, cY = current X and Y position of mouse, updated by mousemove event
// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
var cX, cY, pX, pY;
// A private function for getting mouse position
var track = function(ev) {
cX = ev.pageX;
cY = ev.pageY;
};
// A private function for comparing current and previous mouse position
var compare = function(ev,ob) {
ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
// compare mouse positions to see if they've crossed the threshold
if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
$(ob).unbind("mousemove",track);
// set hoverIntent state to true (so mouseOut can be called)
ob.hoverIntent_s = 1;
return cfg.over.apply(ob,[ev]);
} else {
// set previous coordinates for next time
pX = cX; pY = cY;
// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
}
};
// A private function for delaying the mouseOut function
var delay = function(ev,ob) {
ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
ob.hoverIntent_s = 0;
return cfg.out.apply(ob,[ev]);
};
// A private function for handling mouse 'hovering'
var handleHover = function(e) {
// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
if ( p == this ) { return false; }
// copy objects to be passed into t (required for event object to be passed in IE)
var ev = jQuery.extend({},e);
var ob = this;
// cancel hoverIntent timer if it exists
if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }
// else e.type == "onmouseover"
if (e.type == "mouseover") {
// set "previous" X and Y position based on initial entry point
pX = ev.pageX; pY = ev.pageY;
// update "current" X and Y position based on mousemove
$(ob).bind("mousemove",track);
// start polling interval (self-calling timeout) to compare mouse coordinates over time
if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}
// else e.type == "onmouseout"
} else {
// unbind expensive mousemove event
$(ob).unbind("mousemove",track);
// if hoverIntent state is true, then call the mouseOut function after the specified delay
if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
}
};
// bind the function to the two event listeners
return this.mouseover(handleHover).mouseout(handleHover);
};
})(jQuery);
</script>
<script type="text/javascript" >
/*
* Superfish v1.4.8 - jQuery menu widget
* Copyright (c) 2008 Joel Birch
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
*/
;(function($){
$.fn.superfish = function(op){
var sf = $.fn.superfish,
c = sf.c,
$arrow = $(['<span class="',c.arrowClass,'"> »</span>'].join('')),
over = function(){
var $$ = $(this), menu = getMenu($$);
clearTimeout(menu.sfTimer);
$$.showSuperfishUl().siblings().hideSuperfishUl();
},
out = function(){
var $$ = $(this), menu = getMenu($$), o = sf.op;
clearTimeout(menu.sfTimer);
menu.sfTimer=setTimeout(function(){
o.retainPath=($.inArray($$[0],o.$path)>-1);
$$.hideSuperfishUl();
if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
},o.delay);
},
getMenu = function($menu){
var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
sf.op = sf.o[menu.serial];
return menu;
},
addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
return this.each(function() {
var s = this.serial = sf.o.length;
var o = $.extend({},sf.defaults,op);
o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).ea ch(function(){
$(this).addClass([o.hoverClass,c.bcClass].join(' '))
.filter('li:has(ul)').removeClass(o.pathClass);
});
sf.o[s] = sf.op = o;
$('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
if (o.autoArrows) addArrow( $('>a:first-child',this) );
})
.not('.'+c.bcClass)
.hideSuperfishUl();
var $a = $('a',this);
$a.each(function(i){
var $li = $a.eq(i).parents('li');
$a.eq(i).focus(function(){over.call($li);}).blur(f unction(){out.call($li);});
});
o.onInit.call(this);
}).each(function() {
var menuClasses = [c.menuClass];
if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
$(this).addClass(menuClasses.join(' '));
});
};
var sf = $.fn.superfish;
sf.o = [];
sf.op = {};
sf.IE7fix = function(){
var o = sf.op;
if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
this.toggleClass(sf.c.shadowClass+'-off');
};
sf.c = {
bcClass : 'sf-breadcrumb',
menuClass : 'sf-js-enabled',
anchorClass : 'sf-with-ul',
arrowClass : 'sf-sub-indicator',
shadowClass : 'sf-shadow'
};
sf.defaults = {
hoverClass : 'sfHover',
pathClass : 'overideThisToUse',
pathLevels : 1,
delay : 800,
animation : {opacity:'show'},
speed : 'normal',
autoArrows : true,
dropShadows : true,
disableHI : false, // true disables hoverIntent detection
onInit : function(){}, // callback functions
onBeforeShow: function(){},
onShow : function(){},
onHide : function(){}
};
$.fn.extend({
hideSuperfishUl : function(){
var o = sf.op,
not = (o.retainPath===true) ? o.$path : '';
o.retainPath = false;
var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.h overClass)
.find('>ul').hide().css('visibility','hidden');
o.onHide.call($ul);
return this;
},
showSuperfishUl : function(){
var o = sf.op,
sh = sf.c.shadowClass+'-off',
$ul = this.addClass(o.hoverClass)
.find('>ul:hidden').css('visibility','visible');
sf.IE7fix.call($ul);
o.onBeforeShow.call($ul);
$ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
return this;
}
});
})(jQuery);
</script>
<script type="text/javascript">
// Inicia plugins
jQuery(function(){
jQuery('ul.sf-menu').superfish();
});
</script>
[/HTML]
  #3 (permalink)  
Antiguo 30/05/2012, 09:00
 
Fecha de Ingreso: mayo-2012
Ubicación: En la Tierra
Mensajes: 41
Antigüedad: 11 años, 10 meses
Puntos: 3
Respuesta: Menu Desplegable hacia abajo con js

<script type="text/javascript">
// Inicia plugins
jQuery(function(){
jQuery('ul.sf-menu').superfish();
});
</script>
  #4 (permalink)  
Antiguo 30/05/2012, 09:03
 
Fecha de Ingreso: mayo-2012
Ubicación: En la Tierra
Mensajes: 41
Antigüedad: 11 años, 10 meses
Puntos: 3
Respuesta: Menu Desplegable hacia abajo con js

Código:
<!DOCTYPE html>
<head>
<title></title>
</head><body><ul class="sf-menu"><li class="current"><a href="#a">menu item</a><ul><li><a href="#aa">menu item that is quite long</a></li>
<li class="current"><a href="#ab">menu item</a><ul><li class="current"><a href="#">menu item</a></li><li><a href="#aba">menu item</a></li><li><a href="#abb">menu item</a></li><li><a href="#abc">menuitem</a></li><li><a href="#abd">menu item</a></li></ul></li><li><a href="#">menu item</a>
<ul><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li><li><a href="#">menuitem</a></li><li><a href="#">menu item</a></li></ul></li><li><a href="#">menu item</a><ul><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li></ul></li></ul></li><li><a href="#">menu item</a></li><li><a href="#">menu item</a><ul><li>
<a href="#">menu item</a><ul><li><a href="#">short</a></li><li><a href="#">short</a></li><li><a href="#">short</a></li><li><a href="#">short</a></li><li><a href="#">short</a></li></ul></li><li><a href="#">menu item</a><ul><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li></ul>
</li><li><a href="#">menu item</a><ul><li><a href="#">menu item</a></li>
li><a href="#">menu item</a></li><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li></ul></li>
<li><a href="#">menu item</a><ul><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li></ul></li><li><a href="#">menu item</a><ul><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li><li><a href="#">menu item</a></li></ul></li></ul></li><li><a href="#">menu item</a></li></ul></body></html>
  #5 (permalink)  
Antiguo 30/05/2012, 09:10
 
Fecha de Ingreso: mayo-2012
Ubicación: En la Tierra
Mensajes: 41
Antigüedad: 11 años, 10 meses
Puntos: 3
Respuesta: Menu Desplegable hacia abajo con js

Código:
<style>
/*** ESSENTIAL STYLES ***/
.sf-menu, .sf-menu * {margin:	0; padding:0; list-style:none;}
.sf-menu {line-height:	1.0;}
.sf-menu ul {position:absolute; top:-999em; width:	10em; /* left offset of submenus need to match (see below) */}
.sf-menu ul li {width:100%;}
.sf-menu li:hover {visibility:	inherit; /* fixes IE7 'sticky bug' */}
.sf-menu li {float:	left; position:		relative;}
.sf-menu a {display:	block;position:		relative;}
.sf-menu li:hover ul,.sf-menu li.sfHover ul {left:0; top:2.5em; /* match top ul list item height */z-index:99;}
ul.sf-menu li:hover li ul, ul.sf-menu li.sfHover li ul {top:-999em; }
ul.sf-menu li li:hover ul, ul.sf-menu li li.sfHover ul {left:10em; /* match ul width */
top:0;}
ul.sf-menu li li:hover li ul, ul.sf-menu li li.sfHover li ul {top:-999em;}
ul.sf-menu li li li:hover ul,ul.sf-menu li li li.sfHover ul {left:10em; /* match ul width */ top:0;}
/*** DEMO SKIN ***/
.sf-menu {float:left;margin-bottom:1em;}
.sf-menu a {border-left:1px solid #fff; border-top:1px solid #CFDEFF; padding:	.75em 1em;text-decoration:none;}
.sf-menu a, .sf-menu a:visited  { /* visited pseudo selector so IE6 applies text colour*/color:#13a;}
.sf-menu li {background:		#BDD2FF;}
.sf-menu li li {background:		#AABDE6;}
.sf-menu li li li {background:		#9AAEDB;}
.sf-menu li:hover, .sf-menu li.sfHover,.sf-menu a:focus, .sf-menu a:hover, .sf-menu a:active {background:#CFDEFF;outline:		0;}

/*** arrows **/
.sf-menu a.sf-with-ul {padding-right: 	2.25em;min-width:1px; /* trigger IE7 hasLayout so spans position accurately */}
.sf-sub-indicator {position:absolute; display:block; right:.75em; top:1.05em; /* IE6 only */width:10px; height:10px; text-indent:-999em; overflow:hidden; background:url('../images/arrows-ffffff.png') no-repeat -10px -100px; /* 8-bit indexed alpha png. IE6 gets solid image only */}
a > .sf-sub-indicator {  /* give all except IE6 the correct values */top: 	.8em;
background-position: 0 -100px; /* use translucent arrow for modern browsers*/}
/* apply hovers to modern browsers */a:focus > .sf-sub-indicator,a:hover > .sf-sub-indicator, a:active > .sf-sub-indicator, li:hover > a > .sf-sub-indicator, li.sfHover > a > .sf-sub-indicator {background-position: -10px -100px; /* arrow hovers for modern browsers*/}
/* point right for anchors in subs */ .sf-menu ul .sf-sub-indicator { background-position:  -10px 0; }
.sf-menu ul a > .sf-sub-indicator { background-position:  0 0; }
/* apply hovers to modern browsers */ .sf-menu ul a:focus > .sf-sub-indicator, .sf-menu ul a:hover > .sf-sub-indicator, .sf-menu ul a:active > .sf-sub-indicator,
.sf-menu ul li:hover > a > .sf-sub-indicator, .sf-menu ul li.sfHover > a > .sf-sub-indicator {background-position: -10px 0; /* arrow hovers for modern browsers*/}
/*** shadows for all but IE6 ***/
.sf-shadow ul {background:	url('../images/shadow.png') no-repeat bottom right;
padding: 0 8px 9px 0;-moz-border-radius-bottomleft: 17px; -moz-border-radius-topright: 17px; -webkit-border-top-right-radius: 17px; -webkit-border-bottom-left-radius: 17px;}
.sf-shadow ul.sf-shadow-off {background: transparent; }
</style>
Solo haz los cambios necesarios dentro de las etiquetas <li> de acuerdo a tus necesidades.
  #6 (permalink)  
Antiguo 30/05/2012, 09:26
Avatar de 60NZ4  
Fecha de Ingreso: mayo-2012
Ubicación: 404 Not found
Mensajes: 112
Antigüedad: 11 años, 11 meses
Puntos: 2
Respuesta: Menu Desplegable hacia abajo con js

antes de ponerme a ello muchas gracias tio =)

voy a leerlos a fondo y luego te contare si lo saco una vez mas muchas gracias

__________________
Nadie nace aprendido, un experto es simplemente alguien que ya ha cometido muchos errores
  #7 (permalink)  
Antiguo 30/05/2012, 10:20
Avatar de 60NZ4  
Fecha de Ingreso: mayo-2012
Ubicación: 404 Not found
Mensajes: 112
Antigüedad: 11 años, 11 meses
Puntos: 2
Respuesta: Menu Desplegable hacia abajo con js

Sigo con ello, el resultado es increíble no hay discusión, pero la verdad esque el codigo no lo entiendo, por ello preferiria algo mas simple, relacionado con mi codigo, poner algo asi puede quedar muy bien, pero si no lo entiendo no me ayuda a mejorar, preferia algo mas sencillo , poco a poco llegare a entender el codigo que me has pasado
__________________
Nadie nace aprendido, un experto es simplemente alguien que ya ha cometido muchos errores
  #8 (permalink)  
Antiguo 30/05/2012, 13:43
 
Fecha de Ingreso: mayo-2012
Ubicación: En la Tierra
Mensajes: 41
Antigüedad: 11 años, 10 meses
Puntos: 3
Respuesta: Menu Desplegable hacia abajo con js

Puedes hacer los cambios al codigo en las primeras variables:

Código:
var timeBeforeAutoHide = 700;   // Microseconds to wait before auto hiding menu(1000 = 1 second)
var slideSpeed_out = 10;    // Steps to move sub menu at a time ( higher = faster) var slideSpeed_in = 10;20.       
var slideTimeout_out = 25;  // Microseconds between slide steps ( lower = faster)
var slideTimeout_in = 10;   // Microseconds between slide steps ( lower = faster)
var showSubOnMouseOver = true;  // false = show sub menu on click, true = show sub menu on mouse over
var fixedSubMenuWidth = false;  // Width of sub menu items - A number(width in pixels) or false when width should be dynamic   
var xOffsetSubMenu = 0;     // Offset x-position of sub menu items - use negative value if you want the sub menu to overlap main menu29.     
var slideDirection = 'right';   // Slide to left or right ?
La variable de tu interés es la ultima:

Código HTML:
var slideDirection = 'right';   // Slide to left or right ?
  #9 (permalink)  
Antiguo 04/06/2012, 01:07
Avatar de 60NZ4  
Fecha de Ingreso: mayo-2012
Ubicación: 404 Not found
Mensajes: 112
Antigüedad: 11 años, 11 meses
Puntos: 2
Respuesta: Menu Desplegable hacia abajo con js

Es evidente que deberia cambiar eso, pero hay no hay informacion relevante, ya que en la linea 100 del codigo:

Código Javascript:
Ver original
  1. if(!subPositioned[numericId]){
  2.                     if(slideDirection=='right'){
  3.                         subObj.style.left = getLeftPos(submenuObjArray[numericId]['parentDiv']) + submenuObjArray[numericId]['parentDiv'].offsetWidth + xOffsetSubMenu + 'px';
  4.                     }else{
  5.                         subObj.style.left = getLeftPos(submenuObjArray[numericId]['parentDiv']) + xOffsetSubMenu + 'px';
  6.                        
  7.                     }


hay es donde deberia cambiar algo
__________________
Nadie nace aprendido, un experto es simplemente alguien que ya ha cometido muchos errores
  #10 (permalink)  
Antiguo 04/06/2012, 04:02
Avatar de 60NZ4  
Fecha de Ingreso: mayo-2012
Ubicación: 404 Not found
Mensajes: 112
Antigüedad: 11 años, 11 meses
Puntos: 2
Respuesta: Menu Desplegable hacia abajo con js

Hola de nuevo!!!

tras investigar mucho por google

he conseguido sacar un codigo javascript, que junto con una pequeña modificacion en mi css, he conseguido listarlo hacia abajo, la verdad ahora es mucho mas presentable

aunque no se muy bien como funciona me sirve, lo dicho ya investigare mas afondo javascript porque tengo mucha curiosidad en el tema, pero ahora no tengo tiempo

muchas gracias por tu ayuda

__________________
Nadie nace aprendido, un experto es simplemente alguien que ya ha cometido muchos errores

Etiquetas: abajo, desplegable, hacia, html, input, js
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:44.