Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

navigation dropdown not working

Featured Replies

I just started to work wit Amazium 1200 grid, and i cant figure out this problem. Im using 4 and 8 grid in a row on top, logo will be in grid 4 and navigation in grid 8.

35840nb.jpg

So my problem is that my navigation has dropdown and its not working

first i tried to put z-index 9999 because dropdown goes over Slider - still not working. Then i removed slider and dropdown still not working so it must be something in css but i dont know what.

here is the navigation code (i downloaded free menu)

 

/* General menu styling */
.nav {
	position: relative;
	margin: 0;
	padding: 0;
	line-height: 22px;
	font-family: 'PT Sans Narrow', sans-serif;
	
}
	
	/* The main navigation link containers */
	.nav>li {
		display: block;
		float: left; /* Displaying them on the same line */
		margin: 0;
		padding: 0;
	}

		/* The main navigation links */
		.nav>li>a {
			/* Layout */
			display: block;
			position: relative;
			padding: 10px 20px;

			/* Text */
			font-family: 'PT Sans Narrow', sans-serif;
			color: #fff;
			font-size: 17px;
			text-decoration: none;

			/* Background */
			background: black; /* For older browsers */
			background: rgba(0, 0, 0, .6); /* Transparent background for modern browsers */
			
			/* Making the color to change on hover with a transition */
			-webkit-transition: color .3s ease-in;
			-moz-transition: color .3s ease-in;
			-o-transition: color .3s ease-in;
			-ms-transition: color .3s ease-in;
		}

		/* Changing the color on hover */
		.nav>li>a:hover, .nav>li:hover>a {
			color: #0fd0f9;
		}

		/* The links which contain dropdowns menu are wider, because they have a little arrow */
		.nav>.dropdown>a {
			padding: 10px 30px 10px 20px;

		}

		/* The arrow indicating the dropdown */
		.dropdown>a::after {
			 content: "";
			 position: absolute;
			 top: 17px;
			 right: 10px;
			 width: 7px;
			 height: 7px;
			 -webkit-transform: rotate(45deg);
			 -ms-transform: rotate(45deg);
			 -moz-transform: rotate(45deg);
			 -o-transform: rotate(45deg);
			 border-bottom: 1px solid #fff;
			 border-right: 1px solid #fff;

			}

		/* Changing the color of the arrow on hover */	
		.dropdown>a:hover::after, .dropdown:hover>a::after {
			border-color: #0fd0f9;
			
		}

		/* The submenus */
		.nav ul {
			position: absolute;
			margin: 0;
			padding: 0;
			list-style: none;
			display: block;
			
		}

		/* General layout settings for the link containers of the submenus */
		.nav ul li {
			position: absolute;
			top: -9999px; /* Hiding them */
			height: 0px; 
			display: block;
			margin: 0;
			padding: 0;

			/* Making them to expand their height with a transition, for a slide effect */
			-webkit-transition: height .2s ease-in;
			-moz-transition: height .2s ease-in;
			-o-transition: height .2s ease-in;
			-ms-transition: height .2s ease-in;
		}

		/* Displays the submenu links, by expading their containers (with a transition, previously defined) and by repositioning them */
		.dropdown:hover>ul>li {
			height: 30px;
			position: relative;
			top: auto;
			
		}

			/* The submenu links */
			.nav ul li a {
				/* Layout */
				padding: 4px 20px;
				width: 120px;
				display: block;
				position: relative;

				/* Text */
				font-family: 'PT Sans Narrow', sans-serif;
				color: #bbb;
				text-decoration: none;
				font-size: 16px;
				
				/* Background & effects */
				background: black;
				background: rgba(0, 0, 0, .6);
				-webkit-transition: color .3s ease-in, background .3s ease-in;
				-moz-transition: color .3s ease-in, background .3s ease-in;
				-o-transition: color .3s ease-in, background .3s ease-in;
				-ms-transition: color .3s ease-in, background .3s ease-in;
			}

			/* Changing the link's color and background on hover */
			.nav ul li:hover>a, .nav ul li a:hover {
				color: #0fd0f9;
				background: rgba(0, 0, 0, .75);
			}

			/* Making the level 2 (or higher) submenus to appear at the right of their parent */
			.nav ul .dropdown:hover ul {
				left: 160px;
				top: 0px;
			}

			/* The submenu links have a different arrow which indicates another dropdown submenu */
			.nav ul .dropdown a::after{
				width: 6px;
				height: 6px;
				border-bottom: 0;
				border-right: 1px solid #fff;
				border-top: 1px solid #fff;
				top: 12px;
			}

			/* Changing the color of the arrow on hover */
			.nav ul .dropdown:hover>a::after, .nav ul .dropdown>a:hover::after {
				border-right: 1px solid #0fd0f9;
				border-top: 1px solid #0fd0f9;
			}
.grid_8{ width:608px; margin:0 16px 0 16px; overflow:hidden; float:left; display:inline; }
.grid_4{ width:288px; margin:0 16px 0 16px; overflow:hidden; float:left; display:inline; }
.row{ margin:0 auto; width:960px; overflow:hidden; }

<div class="row">
	<div class="grid_4">4</div>
	<div class="grid_8">
    <div class="meni">
<ul class="nav">
	<li><a href="#">Home</a></li>
	<li class="dropdown">
		<a href="#">Work</a>
		<ul>
			<li><a href="#">Web Design</a></li>
			<li><a href="#">UX Design</a></li>
			<li><a href="#">Development</a></li>
			<li><a href="#">Identity</a></li>
			
	</ul>
	<li><a href="#">Services</a></li>
	<li><a href="#">About</a></li>
	<li><a href="#">Contact</a></li>
</ul>
</div>
</div>
</div>

 

Big thanks in advance for anyone who will take time and help me!

Do you have a live site or larger snippet? I'm not going to try fixing this with just a small snippet of code because the problem may lie elsewhere. Or do you at least have a link to the tutorial/download that you had this from?

 

Also, you haven't closed the <li class="dropdown"> and you have written "meni" instead of "menu" on your div class. Drop-down menu's really aren't that difficult to make so rather than overwhelming yourself by downloading more complicated versions, you're better off just building your own and consequently develop a better understanding of how they work - it makes the troubleshooting process much easier.

  • Author

im from croatia and "meni" = menu (its not from navigation, i made that class), what "meni" does is just float:right in 8grid

 

i dont have live website im still making it, but if u are willing to help me i will upload it

  • Author

I tried to close </li> tag and thats not it, i think that problem is somewhere in

.grid_8{ width:608px; margin:0 16px 0 16px; overflow:hidden; float:left; display:inline; }
.grid_4{ width:288px; margin:0 16px 0 16px; overflow:hidden; float:left; display:inline; }
.row{ margin:0 auto; width:960px; overflow:hidden; }

 

because when i resize the window on 640x 480 i can see a little part of dropdown showing but its not going away from his div (div class grid8)

Yeah, a live example would be much more helpful, can just play with the code live then as well...

The position:absolute on the ul and li really isn't helping. I'd get rid of that as a start!


/* The submenus */
.nav ul {
position: absolute;
margin: 0;
padding: 0;
list-style: none;
display: block;
z-index:1000; /*added z-index*/
}


.nav { /*removed position*/
margin: 0;
padding: 0;
line-height: 22px;
font-family: 'PT Sans Narrow', sans-serif;

}

 

Edited by mteam

  • Author

 

/* The submenus */
		.nav ul {
			position: absolute;
			margin: 0;
			padding: 0;
			list-style: none;
			display: block;
                        z-index:1000; /*added z-index*/
                        }
.nav { /*removed position*/
	margin: 0;
	padding: 0;
	line-height: 22px;
	font-family: 'PT Sans Narrow', sans-serif;
	
}

 

yes thats it! ty so much!

 

can you explain me why removed position in .nav ?

can you explain me why removed position in .nav ?

 

I'm guessing because it's on the whole ul and not the li containing the submenu.

using the position relative is clipping the dropdown.

 

Its a bit strange because your using so many absolute positioned elements and starting with zero heights before easing in the height

 

I thought that was the easiest way to get it working

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.