Font displays different in Chrome and in Firefox - html

I am a bit new when it comes to web development.
I have created a menu but its buttons width are different depending on the browser (Firefox or Chrome)
In Firefox, we can see that the end of the last button of the menu is aligned with the div below. We can also appreciate that the width of the button is 136.5px
However, in Chrome the fonts are bolder and the menu end is pushed a bit forward. Here, the width of the button is 139.281px
This is the site, the menu is on the top: http://www.metagame.gg/champions/
This is the HTML and the CSS code for the menu
.navigator {
margin: 0;
padding: 0;
display: flex;
padding-left: 39px;
background: #8C9BAA;
}
.navigator li {
display: inline-block;
position: relative;
z-index:100;
}
.navigator li a {
text-decoration: none;
font-size: 15px;
display: block;
line-height: 50px;
padding: 2px 27.75px 0px;
-webkit-transition: all 0.2s ease-in-out 0s;
-moz-transition: all 0.2s ease-in-out 0s;
-o-transition: all 0.2s ease-in-out 0s;
-ms-transition: all 0.2s ease-in-out 0s;
transition: all 0.2s ease-in-out 0s;
}
.navigator li a:hover, .navigator li:hover > a {
color:#fff;
background: #7AAFD1;
}
.navigator ul {
display: none;
margin: 0;
padding: 0;
width: 170px;
position: absolute;
left: 0px;
}
.navigator ul li {
display:block;
float: none;
background:none;
margin:0;
padding:0;
}
.navigator ul li a {
font-size:12px;
font-weight:bold;
display:block;
color:#797979;
border-left: 3px solid #ffffff;
background: #fff;
line-height: 42px;
transition: 0s;
}
.navigator ul li a:hover, .menu ul li:hover > a {
background:#EFEFEF;
border-left:3px solid #83BEE4;
color: #12303D;
}
.navigator li:hover > ul {
display: block;
}
.navigator ul ul {
left: 149px;
top: 0px;
}
#in {
color:#fff;
background: #7AAFD1;
}
.sub-menu {
border:1px solid #ddd;
border-top:0px;
border-left:0px;
box-shadow: 3px 5px 5px -5px #3B3B3B;
}
.navigatorSecond {
margin: 0;
padding: 0;
display: flex;
padding-left: 39px;
background: #d1d1d1 ;
}
.navigatorSecond li {
display: inline-block;
position: relative;
z-index:80;
}
.navigatorSecond li a {
font-weight:600;
text-decoration:none;
font-size: 13px;
display:block;
color:#4a4a4a;
line-height: 40px;
padding: 0px 35.3px;
-webkit-transition: all 0.2s ease-in-out 0s;
-moz-transition: all 0.2s ease-in-out 0s;
-o-transition: all 0.2s ease-in-out 0s;
-ms-transition: all 0.2s ease-in-out 0s;
transition: all 0.2s ease-in-out 0s;
}
#ini {
color:#fff;
background: #7AAFD1;
}
.navigatorSecond li a:hover, .navigatorSecond li:hover > a {
color:#fff;
background: #7AAFD1;
}
.navigatorSecond ul {
display: none;
margin: 0;
padding: 0;
width: 170px;
position: absolute;
left: 0px;
}
.navigatorSecond ul li {
display:block;
float: none;
background:none;
margin:0;
padding:0;
}
.navigatorSecond ul li a {
font-size:13px;
font-weight:bold;
display:block;
color:#797979;
border-left: 3px solid #ffffff;
background: #fff;
line-height: 42px;
transition: 0s;
}
<div class="menuWrap">
<ul class="navigator">
<li>HOME</li>
<li>CHAMPIONS</li>
<li>SOLO QUEUE <img class="iconMenu" src="/icon/expandir.png" alt=""/>
<ul class="sub-menu">
<li>Tier List</li>
<li>Basics & Tactics</li>
<li>Psychology</li>
<li>Picks & Bans</li>
<li>Division analysis</li>
</ul>
</li>
<li>PRO SCENE <img class="iconMenu" src="/icon/expandir.png" alt=""/>
<ul class="sub-menu">
<li>Sub-Menu 1</li>
<li>Sub-Menu 2</li>
<li>Sub-Menu 3</li>
</ul>
</li>
<li>IN-DEPTH ANALYSIS</li>
<li>STATISTICS</li>
</ul>
</div>
I think it is because the font is a bit bolder in Chrome and that causes the button width to be higher.
Thanks in advance

Update: This is because each browser has its own font rendering engine.
I replicated your results with your current sans-serif font. The case also occurred when I changed the font to monospace.
I believe you're better off using a non-system font. For instance, I wanted to see what would happen with a typical Google font such as Open Sans, and I found that the issue did not exist when using it.
By the way, good work on that website. It looks nice. TSM! TSM! TSM!

*{margin:0; padding:0;}
put this line in top of your css file. It helps me for different browser. Just let me know that it helps you or not.

.navigatorSecond li {
display: inline-block;
position: relative;
z-index:80;
}
instead of display inline-block use float left. that will not be different. or use .navigatorsecond{font-size=0;}

Related

My submenu on css is not working property and is hiding a few buttons [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
With this code I have problems because just I have this and I want that those submenus comes over the all menu and then we can select it
If we can see Promedio 2 and promedio 3 are behind of or menu
#charset "utf-8";
#menu2,
#menu2 ul,
#menu2 li,
#menu2 a {
margin: 0;
padding: 0;
border: none;
outline: none;
}
/* menu2 */
#menu2 {
width:850px;
height:33px;
margin:0px;
padding:0px;
font-size:13px;
vertical-align:top;
float:left;
border-top-right-radius:10px;
/*background: -webkit-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: -moz-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: -o-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: -ms-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: linear-gradient(top, #7b0100 0%,#7b0100 100%);
*/
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
#menu2 li:hover{
background:#000066;
color:#FF0;
}
#li_menu{
width:80px;
text-align:center;
padding:0px;
margin:0px;
}
#li_submenu{
text-align:left;
}
#menu2 li {
position: relative;
list-style: none;
float: left;
display: block;
height: 34px;
}
/* Links */
#menu2 li a {
display: block;
padding: 0 14px;
margin: 6px 0;
line-height: 28px;
text-decoration: none;
border-left: 1px solid #CCC;
border-right: 1px solid #9000;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 13px;
color: #FFFFFF;
text-shadow: 1px 1px 1px rgba(0,0,0,.6);
-webkit-transition: color .2s ease-in-out;
-moz-transition: color .2s ease-in-out;
-o-transition: color .2s ease-in-out;
-ms-transition: color .2s ease-in-out;
transition: color .2s ease-in-out;
}
#menu2 li:first-child a { border-left: none; }
#menu2 li:last-child a{ border-right: none; }
#menu2 li:hover > a { color: #FFFF00; }
/* Sub menu2 */
#menu2 ul {
position: absolute;
top: 40px;
left: 0;
opacity: 0;
background: #0000FF;
-webkit-border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
-webkit-transition: opacity .25s ease .1s;
-moz-transition: opacity .25s ease .1s;
-o-transition: opacity .25s ease .1s;
-ms-transition: opacity .25s ease .1s;
transition: opacity .25s ease .1s;
}
#menu2 li:hover > ul {
opacity: 1;
}
#menu2 ul li {
height: 0;
overflow: hidden;
padding: 0;
-webkit-transition: height .25s ease .1s;
-moz-transition: height .25s ease .1s;
-o-transition: height .25s ease .1s;
-ms-transition: height .25s ease .1s;
transition: height .25s ease .1s;
}
#menu2 li:hover > ul li {
height: 34px;
overflow: visible;
padding: 0;
}
#menu2 ul li a {
width: 120px;
padding: 4px 0 4px 30px;
margin: 0;
border: none;
border-bottom: 1px solid #4F0002;
}
+++++++++++++++
#menu, #menu ul {
list-style:none;
padding:0;
margin:0;
}
#menu li {
float:center;
position:relative;
line-height: 4.5em;
width: 10em;
}
#menu li ul {
position:absolute;
margin-top:-1em;
margin-left:.5em;
display:none;
}
#menu ul li ul {
margin-top:-3em;
margin-left:7em;
}
#menu a {
display:block;
border-right:0px solid #fff;
color:#FFFFFF;
text-decoration:none;
padding:0 10px;
}
#menu a:hover {
background-color:#0000FF;
color:#fff;
}
#menu ul {
border-top:1px solid #fff;
}
#menu ul a {
border-right:none;
border-right:1px solid #fff;
border-bottom:1px solid #fff;
border-left:1px solid #fff;
background:#0000FF;
}
/* SHOW SUBMENU 1 */
#menu li:hover ul, #menu li.over ul {
display:block;
position: absolute;
}
#menu li:hover ul ul, #menu li.over ul ul {
display:none;
}
/* SHOW SUBMENU 2 */
#menu ul li:hover ul, #menu ul li.over ul {
display:block;
}
+++++++++++++++++++++++++++++++++
<li id="menu">Examenes
<ul>
<li id="menu"><a href="#" >Calendario</a>
<ul id="menu li.over ul">
<li id="menu"><a href="#" >Calendario 1</a>
<ul id="menu li.over ul">
<li id="menu2_ul_li_a"><a href="examen2.php" tag=location_entry>Matematicas</a>
<ul id="menu2_ul_li_a">
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</li>
<li>Fisica
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</li>
<li>E. Fisica
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</li>
<li>Artisticas
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</li>
<li>Historia
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</li>
<li>Taller
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</li>
<li>Biologia
<ul>
<li><a href="examen2.php" >1</a></li>
<li><a href="examen2.php" >2</a></li>
<li><a href="examen2.php" >3</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li id="menu"><a href="#" >Promedio 1ero</a>
<ul id="menu li.over ul">
<li id="menu">Español</li>
<li id="menu">Matematicas</li>
<li id="menu li">Fisica</li>
<li id="menu li">E. Fisica</li>
<li id="menu2 li:hover > ul ">Artisticas</li>
<li id="menu li">Historia</li>
<li id="menu li">Taller</li>
<li id="menu li">Biologia</li>
</ul>
</li>
<li id="menu">Segundo
<ul id="menu li.over ul">
<li>Español</li>
<li>Matematicas</li>
<li>Fisica</li>
<li>E. Fisica</li>
<li>Artisticas</li>
<li>Historia</li>
<li>Taller</li>
<li>Biologia</li>
</ul>
</li>
<li id="menu">Tercero
<ul id="menu li.over ul">
<li>Español</li>
<li>Matematicas</li>
<li>Fisica</li>
<li>E. Fisica</li>
<li>Artisticas</li>
<li>Historia</li>
<li>Taller</li>
<li>Biologia</li>
</ul>
</li>
</ul>
</li>
#menu2,
#menu2 ul,
#menu2 li,
#menu2 a {
margin: 0;
padding: 0;
border: none;
outline: none;
}
/* menu2 */
#menu2 {
width:850px;
height:33px;
margin:0px;
padding:0px;
font-size:13px;
vertical-align:top;
float:left;
border-top-right-radius:10px;
/*background: -webkit-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: -moz-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: -o-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: -ms-linear-gradient(top, #7b0100 0%,#7b0100 100%);
background: linear-gradient(top, #7b0100 0%,#7b0100 100%);
*/
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
#menu2 li:hover{
background:#000066;
color:#FF0;
}
#li_menu{
width:80px;
text-align:center;
padding:0px;
margin:0px;
}
#li_submenu{
text-align:left;
}
#menu2 li {
position: relative;
list-style: none;
float: left;
display: block;
height: 34px;
}
/* Links */
#menu2 li a {
display: block;
padding: 0 14px;
margin: 6px 0;
line-height: 28px;
text-decoration: none;
border-left: 1px solid #CCC;
border-right: 1px solid #9000;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 13px;
color: #FFFFFF;
text-shadow: 1px 1px 1px rgba(0,0,0,.6);
-webkit-transition: color .2s ease-in-out;
-moz-transition: color .2s ease-in-out;
-o-transition: color .2s ease-in-out;
-ms-transition: color .2s ease-in-out;
transition: color .2s ease-in-out;
}
#menu2 li:first-child a { border-left: none; }
#menu2 li:last-child a{ border-right: none; }
#menu2 li:hover > a { color: #FFFF00; }
/* Sub menu2 */
#menu2 ul {
position: absolute;
top: 40px;
left: 0;
opacity: 0;
background: #0000FF;
-webkit-border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
-webkit-transition: opacity .25s ease .1s;
-moz-transition: opacity .25s ease .1s;
-o-transition: opacity .25s ease .1s;
-ms-transition: opacity .25s ease .1s;
transition: opacity .25s ease .1s;
}
#menu2 li:hover > ul {
opacity: 1;
}
#menu2 ul li {
height: 0;
overflow: hidden;
padding: 0;
-webkit-transition: height .25s ease .1s;
-moz-transition: height .25s ease .1s;
-o-transition: height .25s ease .1s;
-ms-transition: height .25s ease .1s;
transition: height .25s ease .1s;
}
#menu2 li:hover > ul li {
height: 34px;
overflow: visible;
padding: 0;
}
#menu2 ul li a {
width: 120px;
padding: 4px 0 4px 30px;
margin: 0;
border: none;
border-bottom: 1px solid #4F0002;
}
+++++++++++++++
#menu, #menu ul {
list-style:none;
padding:0;
margin:0;
}
#menu li {
float:center;
position:relative;
line-height: 4.5em;
width: 10em;
}
#menu li ul {
position:absolute;
margin-top:-1em;
margin-left:.5em;
display:none;
}
#menu ul li ul {
margin-top:-3em;
margin-left:7em;
}
#menu a {
display:block;
border-right:0px solid #fff;
color:#FFFFFF;
text-decoration:none;
padding:0 10px;
}
#menu a:hover {
background-color:#0000FF;
color:#fff;
}
#menu ul {
border-top:1px solid #fff;
}
#menu ul a {
border-right:none;
border-right:1px solid #fff;
border-bottom:1px solid #fff;
border-left:1px solid #fff;
background:#0000FF;
}
/* SHOW SUBMENU 1 */
#menu li:hover ul, #menu li.over ul {
display:block;
position: absolute;
}
#menu li:hover ul ul, #menu li.over ul ul {
display:none;
}
/* SHOW SUBMENU 2 */
#menu ul li:hover ul, #menu ul li.over ul {
display:block;
}
+++++++++++++++++++++++++++++++++
Some important notes:
You really need to clean it up.
Do not repeat id's. They are meant to
be unique.
float: center does not exist
classes with a dot (li.over) are not well supported. Use - or _ (li-over,li_over)
there is more than one way to do this. Here is one. On this solution, you add the class has-submenu to the list element with a submenu

CSS Menu Disappears after Hover

I am learning css and I have created a vertical menu, hovering the mouse over the first menu item shows the sub-menu across. But my problem is, as soon as I move the mouse to the sub-menu, it disappears. How can I make it so it stays there until I clicked one of the sub-menu items? Please help.
Already searched through a lot of examples but none similar to this. I'm new to css and I'm not sure if my approach is the correct for this menu setup requirement. Please enlighten.
#charset "utf-8";
.navLeft {
width: 25%;
margin-top: 0%;
top: auto;
display: inline;
list-style-type: none;
margin-left: 5%;
position: relative;
z-index: 0;
/* [disabled]clear: none; */
}
.navLeft ul li {
list-style-type: none;
width: 6em;
height: 2em;
/* [disabled]list-style-position: inside; */
color: #F14E23;
text-align: center;
background-color: #FFFFFF;
border: 0.5em solid #000000;
margin-bottom: -0.5em;
font-family: alfa-slab-one;
font-style: normal;
font-weight: 400;
padding-top: 2em;
top: auto;
vertical-align: middle;
padding-bottom: 2em;
-webkit-transition: all 0.1s linear 0s;
-o-transition: all 0.1s linear 0s;
transition: all 0.1s linear 0s;
position: relative;
margin-left: -0.5em;
}
.navLeft ul li:hover {
background-color: #F14E23;
color: #FFFFFF;
list-style-type: none;
position: relative;
}
.navLeft ul .about {
float: left;
-webkit-transition: all .1s linear 0s;
-o-transition: all .1s linear 0s;
transition: all .1s linear 0s;
}
.navLeft ul ul li
{
float: left;
}
.navLeft ul .projects {
clear: left;
}
.navLeft ul ul {
display: none;
}
.navLeft ul .about:hover ~ ul{
display: block;
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>STORY</title>
<link href="css/styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<section class="mainMid">
<nav class="navLeft">
<ul>
<li class="about">ABOUT</li>
<ul>
<li class="navBeginning">BEGINNING</li>
<li class="navMnv">Mission<br>
<br>
Vision</li>
<li class="navPeople">People</li>
</ul>
<li class="projects">PROJECTS</li>
<li class="getinvolved">GET<br>
INVOLVED</li>
<li class="records">RECORDS</li>
<li class="donate">DONATE</li>
</ul>
</nav>
</section>
</body>
</html>
Refer this fiddle : http://jsfiddle.net/zt8ffu11/
html:
<section class="mainMid">
<nav class="navLeft">
<ul>
<li class="about">ABOUT
<ul>
<li class="navBeginning">BEGINNING</li>
<li class="navMnv">Mission<br>
<br>
Vision</li>
<li class="navPeople">People</li>
</ul>
</li>
<li class="projects">PROJECTS</li>
<li class="getinvolved">GET<br>
INVOLVED</li>
<li class="records">RECORDS</li>
<li class="donate">DONATE</li>
</ul>
</nav>
</section>
css:
.navLeft {
width: 25%;
margin-top: 0%;
top: auto;
display: inline;
list-style-type: none;
margin-left: 5%;
position: relative;
z-index: 0;
/* [disabled]clear: none; */
}
.navLeft ul li {
list-style-type: none;
width: 6em;
height: 2em;
/* [disabled]list-style-position: inside; */
color: #F14E23;
text-align: center;
background-color: #FFFFFF;
border: 0.5em solid #000000;
margin-bottom: -0.5em;
font-family: alfa-slab-one;
font-style: normal;
font-weight: 400;
padding-top: 2em;
top: auto;
vertical-align: middle;
padding-bottom: 2em;
-webkit-transition: all 0.1s linear 0s;
-o-transition: all 0.1s linear 0s;
transition: all 0.1s linear 0s;
position: relative;
margin-left: -0.5em;
}
.navLeft ul li:hover {
background-color: #F14E23;
color: #FFFFFF;
list-style-type: none;
position: relative;
}
.navLeft ul .about {
float: left;
-webkit-transition: all .1s linear 0s;
-o-transition: all .1s linear 0s;
transition: all .1s linear 0s;
}
.navLeft ul ul li
{
float: left;
}
.navLeft ul .projects {
clear: left;
}
.navLeft ul ul {
display: none;
}
.navLeft ul .about:hover ul{
display: block;
}
and for list structure check is question Proper way to make HTML nested list?

Nav dropdown freaks out and shows different tabs

I'm trying to create a navbar (already done) with a dropdown, but the dropdown keeps spazzing out when I hover over it :(
I made a JS Fiddle of what I've accomplished so far, and I was hoping for some help!
http://jsfiddle.net/kkpp6/
I think it might be due to the display: none; I used in one of the ul's or possibly due to a stupid typo but I can't figure out where!
As well as this, I can't figure out how to make a sub-menu for my sub-menus that already exist.. (so the desc tab has a submenu of swim squad which will also have a sub-menu of other things).. How would I do that? I can't figure out where I would start!
Cheers for all the help in advance!
Try like this: LINK
CSS:
.nav-wrap {
background-color: #125CC1;
text-align: center;
}
ul.navigation-bar li a {
color: #FFFFFF;
background-color: #125CC1;
text-align: center;
padding: 6px;
font-size: 12px;
text-decoration: none;
text-transform: uppercase;
}
ul.navigation-bar li a:hover {
background-color: #06398F;
}
ul.navigation-bar {
text-align: left;
display: inline;
margin: 0;
list-style: none;
}
ul.navigation-bar li {
line-height:28px;
margin-right: -4px;
position: relative;
display: inline-block;
width: 120px;
font-weight: bold;
color: #FFFFFF;
background-color: #125CC1;
text-align: center;
}
ul.navigation-bar li ul {
padding: 0;
position: absolute;
top: 28px;
left: 0;
width: 120px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
ul.navigation-bar li ul li {
background: #125CC1;
display: block;
color: #fff;
}
ul.navigation-bar li ul li:hover {
background: #06398F;
color: #fff;
}
ul.navigation-bar li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
Updated fiddle LINK
Multi-level dropdown menu LINK
On line 38, you set a list to display when the user hovers over a list item. This makes it visible, but also causes the entire menu to shift over so that you're no longer hovering over the list item that triggered that. If you use position:absolute on the list, it won't affect the other elements on the page:
ul.navigation-bar li > ul {
position:absolute;
}
JSFiddle: http://jsfiddle.net/P9SUg/
I also think its because of display:none;, instead of display:none; you should use visibility:hidden;.
and also add
ul.navigation-bar li > ul {
position:absolute;
}
You need to do lot of changes in CSS for making dropdown menu.
.nav-wrap {
background-color: #125CC1;
text-align: center;
}
ul.navigation-bar {
list-style-type: none;
margin: 0;
padding: 0;
}
ul.navigation-bar > li {
display: inline;
position:relative;
}
ul.navigation-bar > li > a {
display: inline-block;
width: 120px;
font-weight: bold;
color: #FFFFFF;
background-color: #125CC1;
text-align: center;
padding: 4px;
font-size: 12px;
text-decoration: none;
text-transform: uppercase;
-webkit-transition: all 0.15s linear;
-moz-transition: all 0.15s linear;
-o-transition: all 0.15s linear;
transition: all 0.15s linear;
}
ul.navigation-bar > li > a:hover {
background-color: #06398F;
}
ul.navigation-bar ul {
display: none;
}
ul.navigation-bar li:hover > ul {
display: block;
position:absolute;
top:23px;
background-color:#ff00ff;
z-index:10;
width:100%;
list-style-type: none;
margin: 0;
padding: 0;
}
ul.navigation-bar li ul li a
{
list-type:none;
text-align: left;
font-weight:normal;
padding: 4px;
font-size: 10px;
text-decoration: none;
text-transform: uppercase;
-webkit-transition: all 0.15s linear;
-moz-transition: all 0.15s linear;
-o-transition: all 0.15s linear;
transition: all 0.15s linear;
}
ul.navigation-bar li ul li:hover
{
background-color:#000;
}
ul.navigation-bar li ul li:hover a
{
color:#fff;
}
FIDDLE DEMO

Hovering over menu item removes left border. How do I leave menu border on hover?

I've got a menu made that utilizes left and right borders to separate each menu item. When hovering over the menu, the background changes to a lighter shade, which is what I want. However, hovering also covers the left border. How can I stop the border from disappearing? I'm sure this has been answered elsewhere, but I couldn't find it. Thanks, in advance.
http://jsfiddle.net/aYsKp/2/
HTML:
<div id="header">
<div id="menu">
<ul>
<li>HOME
</li>
<li>PRODUCTS
</li>
<li>VIDEOS
</li>
<li>DOWNLOADS
</li>
<li>CONTACT
</li>
<li>ABOUT
</li>
</ul>
</div>
</div>
CSS:
#header {
width:960px;
margin: 10px auto 5px auto;
background-color: #727272;
}
#menu {
max-width:828px;
bottom:0;
right:0;
font: 12px/18px sans-serif;
}
#menu a {
text-decoration: none;
display:block;
padding: 10px 32px;
color:#FFF;
}
#menu ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
}
#menu ul li {
display: inline-block;
margin-right: -4px;
position: relative;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
border-right: 1px solid #FFF;
}
#menu ul li:first-child {
border-left: 1px solid #FFF;
}
#menu ul li:hover {
background-color:#818181;
}
Try this approach.
#header {
width:960px;
margin: 10px auto 5px auto;
}
#menu {
max-width:828px;
bottom:0;
right:0;
font: 12px/18px sans-serif;
background-color: white;
}
#menu a {
text-decoration: none;
display:block;
padding: 10px 32px;
color:#FFF;
}
#menu ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
}
#menu ul li {
display: inline-block;
position: relative;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
background-color: #727272;
margin:0;
}
#menu ul li:hover {
background-color:#818181;
}
What I've done is just removed right margin and specified background color as white for the menu div.
I use to set border or space informations in A tag, not in LI, making LI like an "invisible" tag, setting all properties to A, using A display:inline-block.

Make submenu vertical layout in an existing nav menu

I have a menu nav function in css3 and html
<nav>
<ul>
<li><a href="#" >Sec1</a></li>
<li><a href="#" >Sec2</a></li>
<li>Sec3
<ul class="menu">
<li>Documents</li>
<li>Messages</li>
<li>Sign Out</li>
</ul></li>
<li><a href="#" >Sec4</a></li>
</ul>
</nav>
but How can the submenu be like:
instead of:
--Fiddle-
here is fiddle
I understand what you are looking for and have made my jsfiddle as close as possible to yours. Instead of using the images you provided, I used icon fonts, which are useful if you plan on using many images. I got my icon font from Keyamoon at icomoon.io. It's a really good tool to have and you should definitely use it for any other icons you need. I picked mine from Icon Minia by Egemen Kapusuz. You can see the icons I used and if those are the only ones you need just download the files from the #font-face urls in the jsfiddle, or from here:
#font-face {
font-family: 'IHK';
src:url('http://ilanshomekitchen.x10.mx/icon font testing/IHK.eot');
src:url('http://ilanshomekitchen.x10.mx/icon font testing/IHK.eot?#iefix') format('embedded-opentype'),
url('http://ilanshomekitchen.x10.mx/icon font testing/IHK.svg#IHK') format('svg'),
url('http://ilanshomekitchen.x10.mx/icon font testing/IHK.woff') format('woff'),
url('http://ilanshomekitchen.x10.mx/icon font testing/IHK.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
You can just copy the links from here and it will give you the font file to download if you only need these 3 icons. Icon fonts are great because instead of loading 1 image for each background or icon or whatever, you can package the icon fonts all together into 1 HTTP request, making them more efficient in the transfer, and also more customizable. Icon fonts are just a font, so you can also manipulate them much more easily; you can change the color of the font, the anti-aliasing, just like a real text font.
I rewrote your code with some jQuery because yours seemed very jumbled and a little hard to understand, so if you would like to use my exact jsfiddle, you will need to add a jquery source link either from a CDN or host your own copy on your server. jquery.com will have tons of info about that.
So for my HTML:
HTML:
<nav>
<ul>
<li><a href="#" >Sec1</a></li>
<li><a href="#" >Sec2</a></li>
<li>Sec3</li>
<li><a href="contacto.html" >Sec4</a></li>
<ul class="menu">
<li>Documents</li>
<br>
<li>Messages</li>
<br>
<li>Sign Out</li>
</ul>
</ul>
</nav>
The html has some new attributes, which I titled data-icon. I used these to incorporate the icons from the icon font without adding an official element in the DOM. Browser support for this is a little new, so you should look into a redundant icon scheme just in case users are using an old browser that doesn't support icon fonts and the other new features that you also had like border-radius and transitions.
The CSS was modified a lot to use psuedo selectors, which are very useful. Additionally, I now have the nav bar working from jQuery, so it should be supported well because jQuery is a cross-browser JavaScript libary.
The only thing I couldn't fix was this little problem where the hovered text in the 2nd navigation level would jump, I don't know why that happens, I will look into it, but for now, this is what I was able to produce for you.
I Change a little your CSS And Html File
Css:
nav
{
position: absolute;
list-style: none;
text-align: center;
width: 620px;
top: 43px;
right: -12px;
background: transparent;
}
nav ul li
{
float: left;
line-height: normal;
}
nav ul li a
{
font-size: 28px;
font-family: 'Yanone Kaffeesatz', arial, sans-serif;
color: black;
text-transform: capitalize;
font-weight: normal;
display: block; /* IE6, IE7 line height fix */
padding: 15px;
background-color: transparent;
margin-top: 0px;
margin-right: 6px;
text-decoration: none;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
}
nav ul li:hover > ul
{
display: inline;
}
nav ul li a:hover
{
background-color: #43AEF2;
padding: 15px;
color: white;
-moz-border-radius: 8px;
border-radius: 8px;
}
nav ul li a.current
{
background-color: #43aef2;
color: white;
-moz-border-radius: 8px;
border-radius: 8px;
}
nav ul:not(.first) li
{
text-align: center;
display: inline-block;
cursor: pointer;
margin-right: 10px;
color: #666;
transition: 0.3s;
-webkit-transition: 0.3s;
-moz-transition: 0.3s;
-o-transition: 0.3s;
-ms-transition: 0.3s;
}
nav ul:not(.first) li:last-child
{
margin-right: 0;
}
nav ul:not(.first) li:hover
{
color: #000;
}
nav ul:not(.first) li:hover:after
{
color: #bbb;
}
nav ul:not(.first) li:after
{
margin-left: 10px;
content: '';
color: #bbb;
}
nav ul:not(.first) li:last-child:after
{
content: '';
}
.content_menu
{
float: left;
width: 274px;
margin-top: -10px;
margin-bottom: 15px;
}
.content_menu ul
{
margin: 0px;
padding: 0px;
float: none;
}
.content_menu ul li
{
float: none;
padding-bottom: 16px;
}
.content_menu ul li a
{
font-size: 14px;
line-height: normal;
color: #33CC99;
text-align: left;
text-decoration: none;
padding-left: 20px;
}
.content_menu ul li a:hover
{
color: #33CC99;
}
/* submenu */
.menu
{
display: none;
position: absolute;
background: black;
width: 140px;
}
.menu li a
{
display: block;
padding: 0 14px 0 30px;
margin: 6px 0;
line-height: 28px;
text-decoration: none;
border-left: 1px solid #393942;
border-right: 1px solid #4f5058;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 13px;
color: #f3f3f3;
text-shadow: 1px 1px 1px rgba(0,0,0,.6);
-webkit-transition: color .2s ease-in-out;
-moz-transition: color .2s ease-in-out;
-o-transition: color .2s ease-in-out;
-ms-transition: color .2s ease-in-out;
transition: color .2s ease-in-out;
}
.menu li:first-child a
{
border-left: none;
}
.menu li:last-child a
{
border-right: none;
}
.menu li:hover > a
{
color: #33CC99;
}
.menu ul
{
position: absolute;
top: 60px;
left: 0;
opacity: 0;
background: #1f2024;
-webkit-border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
border-radius: 0 0 5px 5px;
-webkit-transition: opacity .25s ease .1s;
-moz-transition: opacity .25s ease .1s;
-o-transition: opacity .25s ease .1s;
-ms-transition: opacity .25s ease .1s;
transition: opacity .25s ease .1s;
}
.menu li:hover > ul
{
opacity: 1;
}
.menu ul li
{
height: 0;
overflow: hidden;
padding: 0;
-webkit-transition: height .25s ease .1s;
-moz-transition: height .25s ease .1s;
-o-transition: height .25s ease .1s;
-ms-transition: height .25s ease .1s;
transition: height .25s ease .1s;
}
.menu li:hover > a
{
height: auto;
}
.menu li a
{
width: 100px;
padding: 4px 0 4px 40px;
margin: 0;
border: none;
border-bottom: 1px solid #353539;
}
.menu ul li:last-child a
{
border: none;
}
/* Icons */
.menu a.documents
{
background: url(http://designmodo.com/demo/css3dropdownmenu/img/docs.png) no-repeat 6px center;
}
.menu a.messages
{
background: url(http://designmodo.com/demo/css3dropdownmenu/img/bubble.png) no-repeat 6px center;
}
.menu a.signout
{
background: url(http://designmodo.com/demo/css3dropdownmenu/img/arrow.png) no-repeat 6px center;
}
.menu li
{
float: none;
display: initial;
}
HTML
<nav>
<ul>
<li><a href="#" >Sec1</a></li>
<li><a href="#" >Sec2</a></li>
<li>Sec3
<ul class="menu">
<li>Documents</li>
<li>Messages</li>
<li>Sign Out</li>
</ul></li>
<li><a href="contacto.html" >Sec4</a></li>
</ul>
</nav>