Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Dec 2015
    Posts
    1
    Member #
    52708

    dropmenu hidden under container

    I got the menú hidden under the container when it's set with opacity, if I remove the opacity from the container, menú is ok (over the container), when I add opacity to the container, menú is showed under this.

    The index.html code:


    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="menubar.css">
    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    <script src="menubar.js"></script>
    <title>WebSite</title>

    <!-- CSS Code -->
    <style type="text/css">
    #nav{
    width:100%;
    margin-left:auto;
    margin-right:auto;
    }
    #section{
    padding-top:3%;
    width:100%;
    margin-left:auto;
    margin-right:auto;
    background-color:lightgray;
    border:2px solid black;
    border-radius:15px;
    opacity:0.85; /* if I remove this line menu is showed ok */
    text-align:center;
    height:10cm;
    }
    </style>
    </head>
    <body>
    <nav id="cssmenu">
    <ul>
    <li><a href="home.html">HOME</a></li>
    <li><a>INFO</a>
    <ul>
    <li><a href="page1.html">PAGE1</a></li>
    <li><a href="page2.html">PAGE2</a></li>
    <li><a href="page3.html">PAGE3</a></li>
    </ul>
    </li>
    <li><a href="disco.html">NEWS</a></li>
    <li><a href="forum.html">MORE</a></li>
    </ul>
    </nav>
    <div style="height:1cm"></div>
    <section id="section"></section>
    </body>
    </html>
    [/CODE]


    The menubar.css code:


    Code:
    	@import url(http://fonts.googleapis.com/css?family=Open+Sans);
    	#cssmenu,
    	#cssmenu ul,
    	#cssmenu ul li,
    	#cssmenu ul li a,
    	#cssmenu #menu-button {
    	  margin: 0;
    	  padding: 0;
    	  border: 0;
    	  list-style: none;
    	  line-height: 1;
    	  display: block;
    	  position: relative;
    	  -webkit-box-sizing: border-box;
    	  -moz-box-sizing: border-box;
    	  box-sizing: border-box;
    	}
    	#cssmenu:after,
    	#cssmenu > ul:after {
    	  content: ".";
    	  display: block;
    	  clear: both;
    	  visibility: hidden;
    	  line-height: 0;
    	  height: 0;
    	}
    	#cssmenu #menu-button {
    	  display: none;
    	}
    	#cssmenu { 
    	  width: auto;
    	  font-family: 'Open Sans', sans-serif;
    	  line-height: 1;
    	  background: #1D1D1D;
    	}
    	#menu-line { 
    	  position: absolute;
    	  top: 0;
    	  left: 0;
    	  height: 3px;
    	  background: #009ae1;
    	  -webkit-transition: all 0.25s ease-out;
    	  -moz-transition: all 0.25s ease-out;
    	  -ms-transition: all 0.25s ease-out;
    	  -o-transition: all 0.25s ease-out;
    	  transition: all 0.25s ease-out;
    	}
    	#cssmenu > ul > li {
    	  float: left;
    	}
    	#cssmenu.align-center > ul {
    	  font-size: 0;
    	  text-align: center;
    	}
    	#cssmenu.align-center > ul > li {
    	  display: inline-block;
    	  float: none;
    	}
    	#cssmenu.align-center ul ul {
    	  text-align: left;
    	}
    	#cssmenu.align-right > ul > li {
    	  float: right;
    	}
    	#cssmenu.align-right ul ul {
    	  text-align: right;
    	}
    	#cssmenu > ul > li > a { 
    	  padding: 20px;
    	  font-size: 12px;
    	  text-decoration: none;
    	  text-transform: uppercase;
    	  color: #ffffff;
    	  -webkit-transition: color .2s ease;
    	  -moz-transition: color .2s ease;
    	  -ms-transition: color .2s ease;
    	  -o-transition: color .2s ease;
    	  transition: color .2s ease;
    	}
    	#cssmenu > ul > li:hover > a,
    	#cssmenu > ul > li.active > a {
    	  color: #009ae1;
    	}
    	#cssmenu > ul > li.has-sub > a {
    	  padding-right: 25px;
    	}
    	#cssmenu > ul > li.has-sub > a::after {
    	  position: absolute;
    	  top: 21px;
    	  right: 10px;
    	  width: 4px;
    	  height: 4px;
    	  border-bottom: 1px solid #ffffff;
    	  border-right: 1px solid #ffffff; 
    	  content: "";
    	  -webkit-transform: rotate(45deg);
    	  -moz-transform: rotate(45deg);
    	  -ms-transform: rotate(45deg);
    	  -o-transform: rotate(45deg);
    	  transform: rotate(45deg);
    	  -webkit-transition: border-color 0.2s ease;
    	  -moz-transition: border-color 0.2s ease;
    	  -ms-transition: border-color 0.2s ease;
    	  -o-transition: border-color 0.2s ease;
    	  transition: border-color 0.2s ease;
    	}
    	#cssmenu > ul > li.has-sub:hover > a::after {
    	  border-color: #009ae1; 
    	}
    	#cssmenu ul ul {
    	  position: absolute;
    	  left: -9999px;
    	}
    	#cssmenu li:hover > ul {
    	  left: auto;
    	}
    	#cssmenu.align-right li:hover > ul {
    	  right: 0;
    	}
    	#cssmenu ul ul ul {
    	  margin-left: 100%;
    	  top: 0;
    	}
    	#cssmenu.align-right ul ul ul {
    	  margin-left: 0;
    	  margin-right: 100%;
    	}
    	#cssmenu ul ul li {
    	  height: 0;
    	  -webkit-transition: height .2s ease;
    	  -moz-transition: height .2s ease;
    	  -ms-transition: height .2s ease;
    	  -o-transition: height .2s ease;
    	  transition: height .2s ease;
    	}
    	#cssmenu ul li:hover > ul > li {
    	  height: 32px;
    	}
    	#cssmenu ul ul li a {
    	  padding: 10px 20px;
    	  width: 160px;
    	  font-size: 12px;
    	  background: #F0F0F0;
    	  opacity:0.95;
    	  text-decoration: none;
    	  color: #333333;
    	  -webkit-transition: color .2s ease;
    	  -moz-transition: color .2s ease;
    	  -ms-transition: color .2s ease;
    	  -o-transition: color .2s ease;
    	  transition: color .2s ease;
    	}
    	#cssmenu ul ul li:hover > a,
    	#cssmenu ul ul li a:hover {
    	  color: #4562A7; 
    	}
    	#cssmenu ul ul li.has-sub > a::after {
    	  position: absolute;
    	  top: 13px;
    	  right: 10px;
    	  width: 4px;
    	  height: 4px;
    	  border-bottom: 1px solid #dddddd;
    	  border-right: 1px solid #dddddd;
    	  content: "";
    	  -webkit-transform: rotate(-45deg);
    	  -moz-transform: rotate(-45deg);
    	  -ms-transform: rotate(-45deg);
    	  -o-transform: rotate(-45deg);
    	  transform: rotate(-45deg);
    	  -webkit-transition: border-color 0.2s ease;
    	  -moz-transition: border-color 0.2s ease;
    	  -ms-transition: border-color 0.2s ease;
    	  -o-transition: border-color 0.2s ease;
    	  transition: border-color 0.2s ease;
    	}
    	#cssmenu.align-right ul ul li.has-sub > a::after {
    	  right: auto;
    	  left: 10px;
    	  border-bottom: 0;
    	  border-right: 0;
    	  border-top: 1px solid #dddddd;
    	  border-left: 1px solid #dddddd;
    	}
    	#cssmenu ul ul li.has-sub:hover > a::after {
    	  border-color: #ffffff;
    	}

    The menubar.js code:



    Code:
    	(function($) {
    	
    	  $.fn.menumaker = function(options) {
    		  
    		  var cssmenu = $(this), settings = $.extend({
    			title: "Menu",
    			format: "dropdown",
    			sticky: false
    		  }, options);
    	
    		  return this.each(function() {
    			cssmenu.prepend('<div id="menu-button">' + settings.title + '</div>');
    			$(this).find("#menu-button").on('click', function(){
    			  $(this).toggleClass('menu-opened');
    			  var mainmenu = $(this).next('ul');
    			  if (mainmenu.hasClass('open')) { 
    				mainmenu.hide().removeClass('open');
    			  }
    			  else {
    				mainmenu.show().addClass('open');
    				if (settings.format === "dropdown") {
    				  mainmenu.find('ul').show();
    				}
    			  }
    			});
    	
    			cssmenu.find('li ul').parent().addClass('has-sub');
    	
    			multiTg = function() {
    			  cssmenu.find(".has-sub").prepend('<span class="submenu-button"></span>');
    			  cssmenu.find('.submenu-button').on('click', function() {
    				$(this).toggleClass('submenu-opened');
    				if ($(this).siblings('ul').hasClass('open')) {
    				  $(this).siblings('ul').removeClass('open').hide();
    				}
    				else {
    				  $(this).siblings('ul').addClass('open').show();
    				}
    			  });
    			};
    	
    			if (settings.format === 'multitoggle') multiTg();
    			else cssmenu.addClass('dropdown');
    	
    			if (settings.sticky === true) cssmenu.css('position', 'fixed');
    	
    			resizeFix = function() {
    			  if ($( window ).width() > 768) {
    				cssmenu.find('ul').show();
    			  }
    	
    			  if ($(window).width() <= 768) {
    				cssmenu.find('ul').hide().removeClass('open');
    			  }
    			};
    			resizeFix();
    			return $(window).on('resize', resizeFix);
    	
    		  });
    	  };
    	})(jQuery);
    	
    	(function($){
    		$(document).ready(function() {
    			$("#cssmenu").menumaker({
    			title: "Menu",
    			format: "multitoggle"
    		});
    		
    		$("#cssmenu").prepend("<div id='menu-line'></div>");
    	
    		var foundActive = false, activeElement, linePosition = 0, menuLine = $("#cssmenu #menu-line"), lineWidth, defaultPosition, defaultWidth;
    	
    		$("#cssmenu > ul > li").each(function() {
    			if ($(this).hasClass('active')) {
    				activeElement = $(this);
    				foundActive = true;
    			}
    		});
    	
    		if (foundActive === false) {
    			activeElement = $("#cssmenu > ul > li").first();
    		}
    	
    		defaultWidth = lineWidth = activeElement.width();
    		defaultPosition = linePosition = activeElement.position().left;
    		menuLine.css("width", lineWidth);
    		menuLine.css("left", linePosition);
    	
    		$("#cssmenu > ul > li").hover(function() {
    			activeElement = $(this);
    			lineWidth = activeElement.width();
    			linePosition = activeElement.position().left;
    			menuLine.css("width", lineWidth);
    			menuLine.css("left", linePosition);
    		}, 
    		
    		function() {
    			menuLine.css("left", defaultPosition);
    			menuLine.css("width", defaultWidth);
    		});
    		
    		$("#section").load("home2.html");
    		$("#cssmenu a").each(function(){
    			var href = $(this).attr("href");
    			$(this).attr({ href: "#"});
    			$(this).click(function(){
    				if (href === "home.html") {
    					window.location.replace("index.html");
    				}
    				else{
    					$("#section").load(href);
    				}
    			});
    		});
    		
    	});
    	})(jQuery);

    Sorry for so much code but I wanted you see the same than me, I guess the problem is not in menubar.css or menubar.js, I guess its only in the index.html.

    Thanks all and sorry for my bad english.

  2.  

  3. #2
    Junior Member
    Join Date
    Dec 2015
    Posts
    11
    Member #
    52700
    Liked
    1 times
    I think you need to use z-index:1 (or higher) for #cssmenu ul ul li a.

  4. #3
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    Actually, you mean #cssmenu ul li ul. That should do the trick.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  5. #4
    Senior Member sasha_bolcina's Avatar
    Join Date
    Sep 2014
    Location
    Serbia
    Posts
    274
    Member #
    40099
    Liked
    47 times
    Block with opacity less than zero has recalculated stacking order. It will be always on top of other elements.
    Sometimes problem can be solved by positioning relative both of parent containers, menu and transparent.
    Also, you can change menu container opacity to 0.99 what will put it in same stacking context with another transparent element... maybe

    Find more about z-index and stacking context: What No One Told You About Z-Index ? Philip Walton


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:50 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com