Results 1 to 2 of 2

Thread: Simple Controls Gallery overlapping menu

  1. #1
    Join Date
    Sep 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Simple Controls Gallery overlapping menu

    1) Script Title: Simple Controls Gallery

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...plegallery.htm

    3) Describe problem:
    I've been using this script for some time now and it works fine, until recently i added a simple css-based (using ordered list) multi-level menu script onto my page. The problem is the simple gallery overlaps the menu (menu on top of the gallery), meaning the menu is hidden behind the gallery.

    I can't remember where I got the menu script from, but the main javascript looks like this:

    Code:
    var menu=function(){
    	var t=15,z=50,s=6,a;
    	function dd(n){this.n=n; this.h=[]; this.c=[]}
    	dd.prototype.init=function(p,c){
    		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
    		for(i;i<l;i++){
    			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
    			h.onmouseover=new Function(this.n+'.st('+i+',true)');
    			h.onmouseout=new Function(this.n+'.st('+i+')');
    		}
    	}
    	dd.prototype.st=function(x,f){
    		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
    		clearInterval(c.t); c.style.overflow='hidden';
    		if(f){
    			p.className+=' '+a;
    			if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
    			if(c.mh==c.offsetHeight){c.style.overflow='visible'}
    			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
    		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
    	}
    	function sl(c,f){
    		var h=c.offsetHeight;
    		if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
    			if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
    			clearInterval(c.t); return
    		}
    		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
    		c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
    		c.style.height=h+(d*f)+'px'
    	}
    	return{dd:dd}
    }();
    Is there a way to modify the Simple Gallery so that it stays behind any pull-down menus?

    Thanks in advance.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That's governed by z-index. In your menu script that appears to be set by the variable z. The gallery uses a top z-index of 1001, so change z in your script as shown:

    Code:
    var menu=function(){
    	var t=15,z=1002,s=6,a;
    	function dd(n){this.n=n; this.h=[]; this.c=[]}
    	dd.prototype.init=fun . . .
    To take effect, z-index depends upon an element's style position being either absolute or relative, and there can be inheritance issues (the parent element must sometimes also have relative or absolute position and a z-index as high as the child) in one or more browsers, otherwise the z-index might not have the desired effect. If any of this is an issue, it can almost always be remedied in the stylesheet and/or by adding a class or id to the menu's markup. But just making the above change may be all that's needed. There's no way to be certain from what you've told so far.

    If you want more help:

    Please post a link to a page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •