Dropdown menu acting weird in IE 9 - html

We have made a dropdown menu for our website and we just have to try it out in different browsers. The dropdown menu works flawlessly in Chrome and Firefox, but in Internet Explorer 9
it acts weird. Here's the problem: Whenever you hover inbetween the space between li's the primary dropdown list shows up. Here's the html code.
<nav>
<ul>
<li class="mainLi"> Matematik
<ul>
<li>Geometri</li>
<li>Algebra</li>
<li>Statistik</li>
</ul>
</li>
<li class="mainLi"> C#
<ul>
<li>Variabler</li>
<li>Villkor</li>
<li>Upprepning</li>
</ul>
</li>
<li class="mainLi"> HTML
<ul>
<li>Taggar</li>
<li>CSS</li>
</ul>
</li>
</ul>
</nav>
Here's the CSS:
.mainLi {
margin-left: 40px;
}
nav ul li {
border-right: 0px solid black;
border-left: 0px solid black;
float: left;
}
nav ul ul {
display: none;
background: #5f6975;
border-radius: 0px;
padding: 0;
position: absolute;
top: 100%;
margin-left: 0%;
}
nav ul li:hover > ul {
display: inline;
}
nav ul ul li a {
color: #fff;
font-size: 21px;
padding: 0.5px 5px;
text-align: center;
}
nav ul ul li a:hover {
background: #4b545f;
}
nav ul ul li {
float: none;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
border-right: 0;
border-left: 0;
position: relative;
list-style-type: none;
top: 100%;
}
nav ul li a {
display: block;
text-decoration: none;
color: black;
font-size: 25px;
}
nav > ul > li:hover > a {
display: block;
}
nav > ul > li:hover {
background: rgb(183,208,226); /* Old browsers */
}
JS Fiddle:
http://jsfiddle.net/K5JGE/

Here is the Solution.
The HTML:
<nav>
<ul>
<li class="mainLi"> Matematik
<ul>
<li>Geometri</li>
<li>Algebra</li>
<li>Statistik</li>
</ul>
</li>
<li class="mainLi"> C#
<ul>
<li>Variabler</li>
<li>Villkor</li>
<li>Upprepning</li>
</ul>
</li>
<li class="mainLi"> HTML
<ul>
<li>Taggar</li>
<li>CSS</li>
</ul>
</li>
</ul>
</nav>
The CSS:
.mainLi {
margin-left: 40px;
}
nav ul li {
border-right: 0px solid black;
border-left: 0px solid black;
float: left;
position:relative;
}
nav ul ul {
display: none;
background: #5f6975;
border-radius: 0px;
padding: 0;
position: absolute;
top: 100%;
margin-left: 0%;
}
nav ul li:hover > ul {
display: inline;
}
nav ul ul li a {
color: #fff;
font-size: 21px;
padding: 0.5px 5px;
text-align: center;
position:relative;
}
nav ul ul li a:hover {
background: #4b545f;
}
nav ul ul li {
float: none;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
border-right: 0;
border-left: 0;
position: relative;
list-style-type: none;
top: 100%;
}
nav ul li a {
display: block;
text-decoration: none;
color: black;
font-size: 25px;
}
nav > ul > li:hover > a {
display: block;
}
nav > ul > li:hover {
background: rgb(183,208,226); /* Old browsers */
}
You just needed to position the child elements accordingly. Thats it.
Hope this Helps.

Also if you take the nav ul ul top:100%; off, it will work too.

That one is working for sure #Nathan Lee.
Aswell you can use this "Template" or whatever you want to call it and make it to your own.
Well, that's what I always do!
DropDownMenu
It's what I use from PSDCenter. (from George Orsmond)
Hope this works good for you too!

Add position: relative; in nav ul li.

Related

hover on anchor tag element with image to appear only on hover

i wanna add that "arrow-down" image on hovering anchor tag element,like shown in the below image. how to achieve that?
here is my code:
HTML:
<div class="menu">
<ul>
<li>HOME</li>
<li>PROFILE</li>
<li>ACHIEVEMENTS</li>
<li>AWARDS</li>
<li>PUBLICATIONS</li>
<li>MEDIA</li>
</ul>
</div>
CSS:
.menu{float:left;margin-left:1%;}
.menu ul li{list-style:none;float:left;margin-right:18px;}
.menu ul li:last-child{margin-right:0;}
.menu ul li a{text-decoration:none;color:#fff; font-family: 'OpenSansSemibold';font-size:14px;border-bottom:3px solid transparent;padding-bottom:5px;}
.menu ul li a:hover{background:url("images/arrow-down.png")no-repeat 50% 100%;border-bottom:3px solid #fff;}
Expanding on Balvant Ahir's response
After you've digged up art of css trianlges
You can use pseudo elements to create a triangle, css below
.menu ul li a:after {
content: "";
width: 0;
height: 0;
border: 6px solid transparent;
border-top-color: white;
position: absolute;
bottom: -15px;
left: 50%;
margin-left: -3px;
}
The arrow is absolutely positioned, so need to set position relative on the link itself
.menu ul li a {
position: relative;
}
That and playing around with display:none and display:block on hover
.menu ul li a:after {
display: none;
}
.menu ul li a:hover:after {
display: block;
}
Should be enough
Demo: https://jsfiddle.net/Varinder/6sa3a4k4/
Something like this ? Don't go for image when you have css to do the job. Check the additional styles.
FIDDLE
.menu ul {
float: left;
margin-left: 1%;
}
.menu ul li {
list-style: none;
float: left;
margin-right: 18px;
}
.menu ul li:last-child {
margin-right: 0;
}
.menu ul li a {
text-decoration: none;
color: #fff;
font-family: 'OpenSansSemibold';
font-size: 14px;
border-bottom: 3px solid transparent;
padding-bottom: 5px;
}
.menu ul li a:hover {
background: url("images/arrow-down.png")no-repeat 50% 100%;
border-bottom: 3px solid #fff;
}
/* additional styles */
.menu {
padding: 5px 20px;
background: #3272B8;
}
.menu:after {
display: table;
clear: both;
content: '';
}
.menu li {
position: relative;
}
.menu li a:after {
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 8px solid #fff;
width: 0;
height: 0;
content: '';
position: absolute;
bottom: -12px;
left: 50%;
transform: translateX(-50%);
visibility: hidden;
}
.menu li a:hover:after {
visibility: visible;
}
<div class="menu">
<ul>
<li>HOME
</li>
<li>PROFILE
</li>
<li>ACHIEVEMENTS
</li>
<li>AWARDS
</li>
<li>PUBLICATIONS
</li>
<li>MEDIA
</li>
</ul>
</div>

<nav> element transparent without any previous opacity/transparency adjustments HTML/CSS

I have noticed my nav bar is transparent and I would like it to not be. I have no previous opacity/transparency set that would cause it to be inheriting the property. I would like to make my nav bar non transparent.
Here is the CSS:
nav {
margin: 20px auto;
text-align: center;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
font-size: 25px;
background: white;
padding: 0px;
border-radius: 10px;
border-style: solid;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: "";
clear: both;
display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: black;
}
nav ul li:hover a {
opacity: 1;
color: white;
}
nav ul li a {
display: block;
padding: 15px 20px;
color: black;
text-decoration: none;
}
nav ul ul {
background: #000000;
border-radius: 0px 0px 10px 10px;
padding: 0;
position: absolute;
top: 100%;
}
nav ul ul li {
float: none;
}
nav ul ul li a {
padding: 15px 20px;
}
nav ul ul li a:hover {
background: #2E2E2E;
border-radius: 10px;
}
#welcome_paragraph {
position: relative;
top: 50px;
width: 500px;
margin: auto;
}
Here is the corresponding HTML:
<nav>
<ul>
<li>Information
<ul>
<li>Getting Started?</li>
<li>About Us</li>
<li>Contact</li>
</ul>
</li>
<li>Starter Kits</li>
<li>Rebuildables
<ul>
<li>Genesis</li>
<li>Dripper</li>
<li>Silica/Cotton</li>
</ul>
</li>
<li>Mods
<ul>
<li>Mechanical</li>
<li>Variable Voltage</li>
</ul>
</li>
<li>Accessories</li>
</ul>
</nav>
<p id="welcome_paragraph">
Welcome, blah blah (this text shows through the nav bar)<br />
</p>
HTML
<nav>
<ul>
<li>Information
<ul>
<li>Getting Started?
</li>
<li>About Us
</li>
<li>Contact
</li>
</ul>
</li>
<li>Starter Kits
</li>
<li>Rebuildables
<ul>
<li>Genesis
</li>
<li>Dripper
</li>
<li>Silica/Cotton
</li>
</ul>
</li>
<li>Mods
<ul>
<li>Mechanical
</li>
<li>Variable Voltage
</li>
</ul>
</li>
<li>Accessories
</li>
</ul>
</nav>
<p id="welcome_paragraph">Welcome, blah blah (this text shows through the nav bar)
<br />
</p>
CSS
nav {
margin: 20px auto;
text-align: center;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
font-size: 25px;
background: white;
padding: 0px;
border-radius: 10px;
border-style: solid;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: "";
clear: both;
display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: black;
position:relative;
z-index:1;
}
nav ul li:hover a {
color: white;
position:relative;
z-index:1;
}
nav ul li a {
display: block;
padding: 15px 20px;
color: black;
text-decoration: none;
}
nav ul ul {
background: #000000;
border-radius: 0px 0px 10px 10px;
padding: 0;
position: absolute;
top: 100%;
}
nav ul ul li {
float: none;
}
nav ul ul li a {
padding: 15px 20px;
}
nav ul ul li a:hover {
background: #2E2E2E;
border-radius: 10px;
}
#welcome_paragraph {
position: relative;
top: 50px;
width: 500px;
margin: auto;
color:white;
}
body
{
background-color:blue;
}
Updated CSS of yours
nav ul li:hover {
background: black;
position:relative;
z-index:1;
}
nav ul li:hover a {
color: white;
position:relative;
z-index:1;
}
Updated Fiddle
Have you tried;
nav {
background: white;
}
Elements are transparent unless you set a background on them or its inherited.
EDIT: If this doesn't help set up a fiddle for us jsfiddle.net.
In your css
nav ul {
font-size: 25px;
background: white;
padding: 0px;
border-radius: 10px;
border-style: solid;
list-style: none;
position: relative;
display: inline-table;
}
background is white.
If you change background to other colour may be your problem will go off. Hope it will help
Cheers !!

add border line for menu li element

i've a menu and i would want to use border on left but here is the desired look how i wanted, i am able to add border but it will take full height of the li element and also i do not want that border to appear on sub menus
example : aunipark.in
here is my code :
html
<div class="menudiv">
<div class="menu">
<ul>
<li>Home</li>
<li>About
<ul>
<li>School</li>
<li>Vision and Mission </li>
<li>Principal’s desk
<li>Management
</ul> </li>
<li>Admission
<ul>
<li>Overview</li>
<li>Download application form</li>
</ul> </li>
<li>Gallery</li>
<li>School Calander</li>
<li>News & Events</li>
<li>Career</li>
<li>Contact</li>
</ul>
</div>
</div>
css
.menudiv
{
width:980px;
}
.menu {
font-family: 'Open Sans', sans-serif;
font-size:14px;
}
.menu ul ul {
display: none;
}
.menu ul li:hover > ul {
display: block;
}
.menu ul {
background: #111312;
margin: 0;
list-style: none;
position: relative;
padding: 0;
border:3px solid #111312;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
}
.menu ul:after {
content: "";
clear: both;
display: block;
}
.menu ul li {
float: left;
border-bottom: 3px solid transparent;
}
.menu ul li:hover {
background: #111312;
border-bottom: 3px solid #fff;
}
.menu ul li:hover a {
color: #fff;
}
.menu ul li a {
display: block;
padding: 15px;
border-right: 3px solid #fff;
color: #fff;
text-decoration: none;
}
.menu ul ul {
background: #111312;
padding: 0;
position: absolute;
top: 100%;
}
.menu ul ul li {
float: none;
position: relative;
}
.menu ul ul li a {
padding: 10px;
color:#000;
display: block;
}
.menu ul ul li a:hover {
background: #111312;
color: #fff;
}
.menu ul ul ul {
position: absolute;
left: 100%;
top:0;
padding: 0;
}
.menu ul ul ul li {
float: none;
border-top: 1px solid #6b727c;
border-bottom: 1px solid pink;
position: relative;
}
.menu ul ul ul li a {
padding: 10px;
color: #fff;
display: block;
}
.menu ul ul ul li a:hover {
background: #95CEF1;
color: #000;
}
.menu ul ul ul ul {
position: absolute;
left: 100%;
top:0;
}
.head
{
width:500px;
height:200px;
background:#789;
}
.foot
{
width:500px;
height:200px;
background:#123;
}
and also the fiddle : jsfiddle.net/p7Nsf/9/
try this....
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Style Test</title>
<style type="text/css">
#list { background-color: aqua; }
.horizontal { display: inline; border-left: 2px solid; padding-left: 0.3em; }
.first { border-left: none; padding-left: 0; }
</style>
</head>
<body>
<div id="list">
<div>
<ul>
<li class="first">Home</li>
<li class="horizontal">About
<ul>
<li class="first">School</li>
<li class="horizontal">Vision and Mission </li>
<li class="horizontal">Principal’s desk
<li class="horizontal">Management
</ul> </li>
<li class="horizontal">Admission
<ul>
<li class="first">Overview</li>
<li class="horizontal">Download application form</li>
</ul> </li>
<li class="horizontal">Gallery</li>
<li class="horizontal">School Calander</li>
<li class="horizontal">News & Events</li>
<li class="horizontal">Career</li>
<li class="horizontal">Contact</li>
</ul>
</div>
</div>
</body>
</html>
Add the padding-top and bottom not to the anchor, but to the li. And give the anchor a border-right:
.menu > ul > li > a {
border-right: 2px solid white;
display: block;
padding-left: 25px;
padding-right: 25px;
}
.menu > ul > li:last-child > a {
border-right: 0;
}
Check here.
Like this
demo
css
.menudiv {
width: 788px;
margin:0 auto;
}
.menu {
font-family: 'Open Sans', sans-serif;
font-size: 14px;
}
.menu ul ul {
display: none;
margin:4px 0 0 0;
}
.menu ul li:hover > ul {
display: block;
}
.menu ul {
background: #111312;
margin: 0;
list-style: none;
position: relative;
padding: 0;
border: 3px solid #111312;
-moz-border-radius: 13px;
-webkit-border-radius: 13px;
border-radius:13px;
}
.menu ul:after {
content: "";
clear: both;
display: block;
}
.menu ul li {
float: left;
border-bottom: 3px solid transparent;
border-right: 3px solid #fff;
}
.menu ul li:last-child{
border:none;
}
}
.menu ul li:hover {
background: #111312;
border-bottom: 3px solid #fff;
}
.menu ul li:hover a {
color: #fff;
}
.menu ul li a {
display: block;
padding: 15px;
color: #fff;
text-decoration: none;
}
.menu ul ul {
background: #111312;
padding: 0;
position: absolute;
top: 100%;
}
.menu ul ul li {
float: none;
position: relative;
border-right:none;
}
.menu ul ul li a {
padding: 10px;
color: #000;
display: block;
}
.menu ul ul li a:hover {
background: #111312;
color: #fff;
}
.menu ul ul ul {
position: absolute;
left: 100%;
top: 0;
padding: 0;
}
.menu ul ul ul li {
float: none;
border-top: 1px solid #6b727c;
border-bottom: 1px solid pink;
position: relative;
}
.menu ul ul ul li a {
padding: 10px;
color: #fff;
display: block;
text-decoration: none;
}
.menu ul ul ul li a:hover {
background: #95CEF1;
color: #000;
}
.menu ul ul ul ul {
position: absolute;
left: 100%;
top: 0;
}
.head {
width: 500px;
height: 200px;
background: #789;
}
.foot {
width: 500px;
height: 200px;
background: #123;
}
The border will always be as tall as the element, but you can draw a line and apply it to all the elements with
background:url(line.png) bottom right no-repeat;
This might be helpfull, I usually handle border lines in navigation with the help of "line-height" property, it allows to control the height borders from left or right sides. In other words you can change the height of a left/right border by changeing "line-height" property.
HTML
<div class="wrapper">
<div class="container">
<ul class="nav">
<li>My Wishlist</li>
<li>My Account</li>
<li>My Cart</li>
<li>Login</li>
</ul>
</div>
</div>
CSS
.wrapper{
background: #f1f1f1;
width: 100%;
border-top: 5px solid #d1b792;
border-bottom: 5px solid #d1b792;
padding-bottom: 1px;
}
.nav li{
display: inline-block;
margin-left: -4px;
}
.nav li a{
display: block;
font-size: 18px;
padding: 0px 12px 3px 12px;
margin: 5px 0;
color: #666694;
line-height: 12px;
border-right: 2px solid #4679BD;
text-decoration: none;
}
.nav li a:hover{
color: darkblue;
}
.nav li:last-child a{
border-right: none;
}
Here is the Fiddle: http://jsfiddle.net/johannesMt/Lt143z8x/

menu hovering and padding on top and bottom

i've a menu with sub menus in it, i've added border at bottom while hovering but when i hover on the menu the menu height increases a bit, the whole menu takes a space at top and bottom when i put it in a div.
here is my fiddle : http://jsfiddle.net/p7Nsf/
<div class="head"></div>
<div class="menudiv">
<div class="menu">
<ul>
<li>Home</li>
<li>About
<ul>
<li>School</li>
<li>Vision and Mission </li>
<li>Principal’s desk
<li>Management
</ul> </li>
<li>Admission
<ul>
<li>Overview</li>
<li>Download application form</li>
</ul> </li>
<li>Gallery</li>
<li>School Calander</li>
<li>News & Events</li>
<li>Career</li>
<li>Contact</li>
</ul>
</div>
</div><!-- menu div ends-->
<div class="foot"></div>
CSS
.menudiv
{
width:980px;
}
.menu {
font-family: 'Open Sans', sans-serif;
font-size:14px;
}
.menu ul ul {
display: none;
}
.menu ul li:hover > ul {
display: block;
}
.menu ul {
background: #111312;
list-style: none;
position: relative;
display: inline-table;
border:3px solid #111312;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
}
.menu ul:after {
content: "";
clear: both;
display: block;
}
.menu ul li {
float: left;
}
.menu ul li:hover {
background: #111312;
border-bottom: 3px solid #fff;
}
.menu ul li:hover a {
color: #fff;
}
.menu ul li a {
display: block;
padding-top: 10px; padding-left: 25px; padding-right: 25px; padding-bottom: 10px;
color: #fff;
text-decoration: none;
}
.menu ul ul {
background: #111312;
padding: 0;
position: absolute;
top: 100%;
}
.menu ul ul li {
float: none;
position: relative;
}
.menu ul ul li a {
padding: 10px;
color:#000;
display: block;
}
.menu ul ul li a:hover {
background: #111312;
color: #fff;
}
.menu ul ul ul {
position: absolute;
left: 100%;
top:0;
padding: 0;
}
.menu ul ul ul li {
float: none;
border-top: 1px solid #6b727c;
border-bottom: 1px solid pink;
position: relative;
}
.menu ul ul ul li a {
padding: 10px;
color: #fff;
display: block;
}
.menu ul ul ul li a:hover {
background: #95CEF1;
color: #000;
}
.menu ul ul ul ul {
position: absolute;
left: 100%;
top:0;
}
.head
{
width:500px;
height:200px;
background:#789;
}
.foot
{
width:500px;
height:200px;
background:#123;
}
Try this, your menu item jumps because you are adding border to the item so it increases its height by the 3 px border
.menu ul li {
float: left;
border-bottom: 3px solid transparent;
}
http://jsfiddle.net/p7Nsf/1/
reduce padding on the anchor to compensate for the 3px
.menu ul li a {
padding-bottom: 7px;
}
http://jsfiddle.net/p7Nsf/2/
Update
.menu ul {
background: none repeat scroll 0 0 #111312;
border: 3px solid #111312;
display: inline-table;
list-style: none outside none;
margin: 0;
padding: 0;
position: relative;
}
I removed the display prop
http://jsfiddle.net/p7Nsf/4/

How do I get my logo and tagline to line up with my navigation?

I have been working on a drop down navigation which I have got close to how I like but I'm having trouble figuring out how to get the Logo (which is really just h1 text) and the tagline, to line up with my navigation.
The html for the logo and tagline is:
<div class="logo grid_5 omega">
<ul>
<li><h1>karma.</h1></li>
<li><p id="tagline">A stop motion animation</p></li>
</ul>
</div>
And it's corresponding CSS is this so far:
/* Header (Logo) -------------------------------------------------- */
.header.grid_12.omega {
margin-top:40px;
box-shadow:0 3px 10px #222;
background:#FFFFFF;
}
.logo.grid_5.omega {
float:left;
}
The navigation's html is:
<nav class="grid_7 omega">
<ul>
<li>About</li>
<li>Process
<ul>
<li>Models</li>
<li>Backgrounds</li>
<li>Animation</li>
<li>Post-production</li>
</ul>
</li>
<li>Style</li>
<li>Reflection</li>
</ul>
</div>
</nav>
And it's CSS is:
/* Drop down nav ---------------------------------------- */
nav ul ul {
display:none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
background: #FFF;
padding: 0 20px;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: ""; clear: both; display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: #4b545f;
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block; padding: 25px 40px;
color: #757575; text-decoration: none;
}
nav ul ul {
background: #5f6975; border-radius: 0px; padding: 0;
position: absolute; top: 100%;
}
nav ul ul li {
float: none;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position: relative;
}
nav ul ul li a {
padding: 15px 40px;
color: #fff;
}
nav ul ul li a:hover {
background: #4b545f;
}
However, as you can see: it's a little off:
http://imgur.com/HDofl9a
Give an id to your main ul and give some top margin?
HTML
<nav class="grid_7 omega">
<ul id="navi">
<li>About</li>
...
</ul>
</nav>
CSS
ul#navi{
margin:30px 0 0 0; /*adjust your top margin*/
}
I think you are looking for this
html
<div class="logo grid_5 omega">
<ul>
<li><h1>karma.</h1></li>
<li><p id="tagline">A stop motion animation</p></li>
</ul>
</div>
<nav class="grid_7 omega navigation">
<ul>
<li>About</li>
<li>Process
<ul>
<li>Models</li>
<li>Backgrounds</li>
<li>Animation</li>
<li>Post-production</li>
</ul>
</li>
<li>Style</li>
<li>Reflection</li>
</ul>
</div>
</nav>
css
.header.grid_12.omega {
margin-top:40px;
box-shadow:0 3px 10px #222;
background:#FFFFFF;
}
.logo.grid_5.omega {
float:left;
}
.logo.grid_5.omega li{
float: left;
line-height: 40px;
list-style-type: none;
margin-right: 25px;
padding-top: 14px;
}
.navigation{
float:left;
}
nav ul ul {
display:none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
background: #FFF;
padding: 0 20px;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after {
content: ""; clear: both; display: block;
}
nav ul li {
float: left;
}
nav ul li:hover {
background: #4b545f;
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block; padding: 25px 40px;
color: #757575; text-decoration: none;
}
jsFiddle File