My centered menu bar wraps on screens smaller than desktop mode picture attached and I've tried several css code to make menu items appear on a single line which have not worked. Can anyone help me with this?
This is the bit of code I added in my CSS editor to center the navigation bar:
#navigation {
position: relative;
}
#main-nav {
clear: left;
float: left;
list-style: none;
margin: 0;
padding: 0;
position: relative;
left: 50%;
text-align: center;
}
.nav li {
display: block;
float: left;
list-style: none;
margin: 0;
padding: 0;
position: relative;
right: 24%;
}
.nav li:hover, .nav li.hover {
position: relative;
}
.nav li ul li {
left: 0;
}
I noticed especially that the .nav li part controls the positioning of the navigation bar.
My html code for the navigation bar is below:
<div class="col-sm-6 col-md-3 footer-sidebar-wrap">
<aside id="nav_menu-2" class="widget widget_nav_menu"><h3 class="widget-title">Menu</h3><div class="menu-primary-menu-container"><ul id="menu-primary-menu-1" class="menu"><li class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-260">Home</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-116">Shop</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-117">About</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-113">Contact</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page current_page_parent menu-item-114">News</li>
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-115">Account</li>
</ul></div></aside> </div>
The full css code for the navigation bar is here:
.page .navbar-custom {
background-color: rgba(10, 10, 10, .9) !important;
}
.navbar-custom {
background-color: rgba(10, 10, 10, .9);
border: 0;
border-radius: 0;
z-index: 1000;
font-family: "Roboto Condensed", sans-serif;
text-transform: uppercase;
letter-spacing: 3px;
font-size: 11px;
-webkit-transition: background, padding 0.4s ease-in-out 0s;
-moz-transition: background, padding 0.4s ease-in-out 0s;
-ms-transition: background, padding 0.4s ease-in-out 0s;
-o-transition: background, padding 0.4s ease-in-out 0s;
transition: background, padding 0.4s ease-in-out 0s;
}
.navbar a {
-webkit-transition: color 0.125s ease-in-out 0s;
-moz-transition: color 0.125s ease-in-out 0s;
-ms-transition: color 0.125s ease-in-out 0s;
-o-transition: color 0.125s ease-in-out 0s;
transition: color 0.125s ease-in-out 0s;
}
.navbar-custom .sub-menu,
.navbar-custom .children {
background: rgba(26, 26, 26, .9);
border-radius: 0;
border: 0;
padding: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.navbar-custom .navbar-brand {
letter-spacing: 4px;
font-weight: 400;
font-size: 22px;
color: #fff;
}
.navbar-custom .sub-menu li,
.navbar-custom .children li {
list-style:none;
}
.navbar-custom .sub-menu li a,
.navbar-custom .children li a {
width:100%;
display:block;
}
.navbar-custom .nav li > a {
position: relative;
color: rgba(255, 255, 255, .7);
}
.navbar-custom .sub-menu > li > a,
.navbar-custom .children > li > a {
border-bottom: 1px solid rgba(73, 71, 71, 0.15) !important;
padding: 11px 15px;
letter-spacing: 2px;
color: #999;
}
.navbar-custom .sub-menu .sub-menu,
.navbar-custom .children .children {
border-left: 1px solid rgba(73, 71, 71, 0.15);
left: 100%;
right: auto;
top: 0;
margin-top: 0;
}
.navbar-custom .sub-menu.left-side .sub-menu,
.navbar-custom .children.left-side .children {
border: 0;
border-right: 1px solid rgba(73, 71, 71, 0.15);
right: 100%;
left: auto;
}
.navbar-custom .nav > li > a:focus,
.navbar-custom .nav > li > a:hover,
.navbar-custom .nav .open > a,
.navbar-custom .nav .open > a:focus,
.navbar-custom .nav .open > a:hover,
.navbar-custom .sub-menu > li > a:focus,
.navbar-custom .sub-menu > li > a:hover {
background: none;
color: #fff;
}
.navbar-custom .sub-menu > li > a:hover,
.navbar-custom .children > li > a:hover {
background: rgba(255, 255, 255, .1) !important;
}
.navbar-custom .menu-item-has-children-toggle:after {
position: absolute;
display: block;
right: 0;
top: 50%;
margin-top: -6px;
font: normal normal normal 14px/1 'ElegantIcons';
font-size: 9px;
content: "\43";
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.navbar-custom .navbar-toggle .icon-bar {
background: #fff;
}
.navbar-nav .menu-item-has-children>a:after,
.navbar-nav .page_item_has_children>a:after {
position: absolute;
display: block;
right: 0;
top: 50%;
margin-top: -6px;
font: normal normal normal 14px/1 ElegantIcons;
font-size: 9px;
content: "\43";
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.navbar-nav .sub-menu,
.navbar-nav .children {
min-width: 180px;
font-size: 11px;
}
.navbar-right ul {
text-align: left;
}
/* Navbar search */
.menu-item-has-children-search {
position: relative;
padding: 5px;
}
.menu-item-has-children-search .form-control {
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
text-transform: uppercase;
letter-spacing: 2px;
font-size: 11px;
}
.search-btn {
position: absolute;
background: transparent;
border: none;
overflow: hidden;
top: 50%;
right: 1px;
width: 42px;
height: 40px;
line-height: 38px;
font-size: 14px;
outline: none;
color: #999;
margin-top: -20px;
}
This occurs because your <li> elements are exceeding the width of the parent <ul> element.
I imagine you could use
li {
white-space: nowrap;
}
This will stop the wrap behavior, however, will not be centered.
I would solve this issue with media queries, or making your parent <ul> element wider in general.
To use media queries use the following template:
#media (max-width: 1000px) {
//place the CSS you want to be activated when the screen is smaller than 1000px here
ul{
width: 1000px;
}
li{
font-size: 10px;
}
}
One other thing that could occur is white-space between <li> or <h3> elements. The reason this is a problem is if those six <li> or <h3> tags' width all equal 100%, then those extra spaces will go over 100% width making the last element fall to the next line. The below code might do the trick.
h3 {
padding:0;
margin:0;
}
Related
I have to add a subnav in an existing nav using a CSS style to reach php page.
Existing nav was : nav > ul > li > a href (ok)
I did:
nav > ul > li > a href (ok)
nav > ul > li > ul > li > a href (ko)
I actually can't hover href (ko) with the cursor : items subnav disappear !
I search in CSS style but I don't really understand how it's works.
I want to click on the 2 pages linked in subnav bellow :
accountCustomerAll.php and serviceViewAll.php.
If you have an idea...
Here is my HTML code :
/* Nav Meu Styling */
.nav-menu li a {
padding: 0px;
text-decoration: none;
display: inline-block;
color: #222222;
font-weight: 500;
font-size: 12px;
text-transform: uppercase;
outline: none;
-webkit-transition: all 0.3s ease 0s;
-moz-transition: all 0.3s ease 0s;
-o-transition: all 0.3s ease 0s;
transition: all 0.3s ease 0s; }
.nav-menu li a.active, .nav-menu li a:hover {
color: #0093df !important; }
.nav-menu li:hover > a {
color: #000; }
.nav-menu > li {
margin-left: 30px; }
.nav-menu ul {
margin: 28px 0 0 0;
padding: 10px;
box-shadow: 0px 0px 30px rgba(127, 137, 161, 0.25);
background: #fff; }
.nav-menu ul li {
transition: 0.3s; }
.nav-menu ul li a {
padding: 5px 10px;
color: #333;
transition: 0.3s;
display: block;
font-size: 12px;
text-transform: none; }
.nav-menu ul li:hover > a {
color: #0093df; }
.nav-menu ul ul {
margin-right: 10px;
margin-top: 0; }
<nav id="nav-menu-container">
<ul class="nav-menu">
<li><a>Gérer l'Aérodrome</a>
<ul>
<li>Consulter les clients</li>
<li>Consulter les commandes</li>
</ul>
</li>
</ul>
</nav>
This could be helpful for you. You have to apply different css on inner <ul>.
/* /* Nav Meu Styling */
.nav-menu li {
float: left;
list-style: none; }
.nav-menu li a {
padding: 0px;
text-decoration: none;
display: inline-block;
color: #222222;
font-weight: 500;
font-size: 12px;
text-transform: uppercase;
outline: none;
-webkit-transition: all 0.3s ease 0s;
-moz-transition: all 0.3s ease 0s;
-o-transition: all 0.3s ease 0s;
transition: all 0.3s ease 0s;
}
.nav-menu li a.active,
.nav-menu li a:hover {
color: #0093df !important;
}
.nav-menu li:hover>a {
color: #000;
}
.nav-menu>ul {
padding: 10px;
box-shadow: 0px 0px 30px rgba(127, 137, 161, 0.25);
background: #fff;
}
.nav-menu ul li {
transition: 0.3s;
transition: 0.3s;
width: 75%;
}
.nav-menu ul li a {
padding: 5px 10px;
color: #333;
transition: 0.3s;
display: block;
font-size: 12px;
text-transform: none;
}
.nav-menu ul li:hover>a {
color: #0093df;
}
.nav-menu ul ul {
margin-right: 10px;
margin-top: 0;
}
.sub-menu {
display: none;
}
.sub-menu>li {
list-style: none;
float: left;
}
ul.nav-menu li a:hover+ul.sub-menu {
display: block;
}
ul.sub-menu:hover {
display: block;
}
<nav id="nav-menu-container">
<ul class="nav-menu">
<li><a>Gérer l'Aérodrome</a>
<ul class="sub-menu">
<li>Consulter les clients</li>
<li>Consulter les commandes</li>
</ul>
</li>
</ul>
</nav>
.nav-menu li a.active, .nav-menu li a:hover{ color: #0093df !important;}
Buggy :active, should be:
.nav-menu li a:active, .nav-menu li a:hover{ color: #0093df}
Please, don't use !importand, debug instead.
Nested structures are hard to maintain, easier would be
<ul><li> <ol><li> ... </li></ol></li></ul>
it is absolutely allowed to style <ol> without numbers.
I have a nav list that i centered, but there is some default spacing that i don't want. Also in the fiddle example you can't see it, but on my end the nav list isn't really centered with the same css etc. Maybe someone can look at the code to see if it really centers the nav list.
--> Fiddle
<header>
<nav>
<ul>
<li><span>Home</span></li>
<li><span>Work</span></li>
<li><span>Information</span></li>
</ul>
</nav>
</header>
You should remove the whitespace between the li elements. As example jsFiddle
<ul>
<li><span>Home</span></li><li>
<span>Work</span></li><li>
<span>Information</span></li>
</ul>
You can set font-size: 0 to ul element and on li the one you want. For example:
/************************************************
Site Name:
Author:
************************************************/
html {
margin: 0;
padding: 0;
position: relative;
min-height: 100%;
overflow-y: scroll;
}
body {
font-family: regular, helvetica, arial, sans-serif;
font-weight: normal;
font-size: 18px;
line-height: 1.4;
text-transform: none;
letter-spacing: 0;
color: #111;
}
body,
input,
textarea,
select,
button {
text-rendering: optimizeLegibility;
-webkit-font-smoothing: subpixel-antialiased;
-moz-osx-font-smoothing: grayscale;
}
:hover {
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
b,
strong {
font-weight: normal;
}
a,
a:visited {
color: #111;
text-decoration: underline;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
-webkit-tap-highlight-color: transparent;
}
h1,
nav {
font-size: 18px;
font-weight: normal;
text-transform: uppercase;
text-decoration: none;
text-align: center;
letter-spacing: 2px;
background-color: transparent;
}
h1 {
margin: 0 0 26px 0;
}
p {
margin: 0 0 16px 0;
background-color: transparent;
}
p a:hover,
a:focus,
a:active {
color: #111;
text-decoration: none;
}
h1 a,
a:visited {
color: #111;
text-decoration: none;
}
h1 a:hover,
a:focus,
a:active {
color: #111;
text-decoration: underline;
}
.center {
width: 500px;
height: 500px;
margin: 0 auto;
background-color: green;
}
/************************************************
Header - Footer - Navigation
************************************************/
header {
position: fixed;
width: 100%;
line-height: 55px;
top: 0;
left: 0;
margin: 0;
padding: 0;
z-index: 9999;
background-color: rgba(0, 0, 0, 0.70);
}
/* Navigation */
nav {
display: block;
text-align: center;
}
nav ul {
list-style-type: none;
padding: 0;
margin: 0;
font-size: 0;
/*set font size 0*/
}
nav li {
display: inline-block;
padding: 0 0;
font-size: 16px;
}
nav a {
position: relative;
display: block;
color: white;
text-decoration: none;
background-color: red;
}
nav a:visited,
a:active {
color: white;
text-decoration: none;
}
nav a:hover span {
transition: none;
text-decoration: none;
border-bottom: 2px solid white;
}
/* Dropdown */
/*nav li:hover a {
background-color: #444;
}
nav li ul {
position: absolute;
float: left;
z-index: 1;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
nav li:hover ul {
opacity: 1;
visibility: visible;
}
nav li ul li {
float: none;
width: 100%;
}
nav li ul a:hover {
color: #999;
}*/
<header>
<nav>
<ul>
<li><span>Home</span>
</li>
<li><span>Work</span>
</li>
<li><span>Information</span>
</li>
</ul>
</nav>
</header>
<div class="center"></div>
You can also set a border to li elements to seperate from each other.
Another way is to use the comment tags between the lines.
<ul>
<li><span>Home</span></li><!--
--><li><span>Work</span></li><!--
--><li><span>Information</span></li>
</ul>
my problem is that when I hover over the area where the hidden list is, it shows the hidden list. I only want it to show the hidden list when hovered over the 'Language' link on the dropdown menu. Why is it doing this, it's probably something blindingly obvious that I can't spot.
Cheers :)
EDIT: I've already tried using a fixed height for the #lang_bar. I also need the transitions to still work. I've already tried using the display:none and display:block; but that didn't work so I used visibility instead.
Any ideas?
HTML:
<div id="lang_bar">
<ul>
<li><strong>Language</strong>
<ul>
<li><strong>Maori</strong></li>
<li><strong>Tongan</strong></li>
<li><strong>Chinese</strong></li>
<li><strong>Japanese</strong></li>
<li><strong>Korean</strong></li>
</ul>
</ul>
</div>
#lang_bar {
font-family: 'Open Sans', sans-serif;
color: white;
padding-left: 152px;
text-transform: uppercase;
z-index: 40;
position: absolute;
padding-top: 2px;
top: 0;
}
#lang_bar ul ul li a {
padding-top: 3px;
padding-left:5px;
}
#lang_bar ul li ul li a:before {
content: '';
display:block;
right: 0px;
height: 2px;
bottom:117px;
width: 100px;
position: absolute;
background: rgba(255, 255, 255, 0.2);
}
#lang_bar ul li ul li a:after {
content: '';
display:block;
right: 1px;
height: 2px;
width: 100px;
position: absolute;
background: rgba(255, 255, 255, 0.6);
}
#lang_bar li, #lang_bar li ul {
text-decoration: none;
list-style-type: none;
}
#lang_bar ul {
list-style: none;
padding-left: 0px;
}
#lang_bar ul li {
float: left;
width: 100px;
text-align: left;
line-height: 21px;
}
#lang_bar ul li a {
display: block;
color: #FFF;
background: transparent;
text-decoration: none;
text-align: center;
}
#lang_bar ul li ul {
visibility: hidden;
font-size:12px;
opacity: 0;
}
#lang_bar ul li:hover ul {
opacity: 1;
visibility: visible; /* display the dropdown */
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
}
#lang_bar ul li ul a:hover{
transition-duration: 0.6s;
background-color: rgba(255, 0, 0, 0.23);
}
I changed your css a little bit and here is the result
I used display:none and display: block in place of visibility, and everything is working as it should be.
http://jsfiddle.net/sy3qowxs/5/enter link description here
And here is your final CSS:
#lang_bar {
font-family: 'Open Sans', sans-serif;
color: #123111;
padding-left: 152px;
text-transform: uppercase;
z-index: 40;
position: absolute;
padding-top: 2px;
top: 0;
}
#lang_bar a:link{color:#333333;}
#lang_bar ul ul li a {
padding-top: 3px;
padding-left:5px;
}
#lang_bar ul li ul li a:before {
content: '';
display:block;
right: 0px;
height: 2px;
bottom:117px;
width: 100px;
position: absolute;
background: rgba(255, 255, 255, 0.2);
}
#lang_bar ul li ul li a:after {
content: '';
display:block;
right: 1px;
height: 2px;
width: 100px;
position: absolute;
background: rgba(255, 255, 255, 0.6);
}
#lang_bar li, #lang_bar li ul {
text-decoration: none;
list-style-type: none;
}
#lang_bar ul {
list-style: none;
padding-left: 0px;
}
#lang_bar ul li {
float: left;
width: 100px;
text-align: left;
line-height: 21px;
}
#lang_bar ul li a {
display: block;
color: #FFF;
background: transparent;
text-decoration: none;
text-align: center;
}
#lang_bar ul li ul {
display: none;
font-size:12px;
opacity: 0;
}
#lang_bar ul li:hover ul {
opacity: 1;
display: block; /* display the dropdown */
-webkit-transition: all .25s ease;
-moz-transition: all .25s ease;
-ms-transition: all .25s ease;
-o-transition: all .25s ease;
transition: all .25s ease;
}
#lang_bar ul li ul a:hover{
transition-duration: 0.6s;
background-color: rgba(255, 0, 0, 0.23);
}
As an alternative to the display: none solution, for accessibility reasons you can use position:absolute and then move the hidden element off screen:
ul li ul {
position:absolute;
top:-1000px;
}
ul li:hover ul {
top:auto;
}
It should work with visibility, since it hides the element (like display: none) but doesn't remove it from the DOM
Here is a working example: Dropdown Menu
HTML
<ul class="menu">
<li class="menu-item"> Dropdown Menu
<ul class="submenu">
<li class="submenu-item">Link</li>
<li class="submenu-item">Link</li>
<li class="submenu-item">Link</li>
<li class="submenu-item">Link</li>
<li class="submenu-item">Link</li>
</ul>
</li>
</ul>
CSS
.menu-item {
position: relative;
}
.menu-item:hover .submenu {
visibility: visible;
opacity: 1;
}
.submenu {
position: absolute;
visibility: hidden;
transition: all .2s ease;
opacity: 0;
top: 100%;
}
.submenu-item {
padding: .4em;
}
What about just using the adjacent sibling combinator:
Change: #lang_bar ul li:hover ul
To: #lang_bar ul li a:hover + ul
To add to the previous answer, the reason this works when you use the display property instead of visibility is because display removes the element from the document flow, and other elements reflow in its place. Visibility, on the other hand, hides the element, but leaves the empty space as if it were still there. So when you used visibility: hidden, your list item looked like it just contained the text "Language" and the link, but the hidden ul was still there, and still hoverable. That's why when you hovered over where the list item should have been, it reappeared; technically, you were hovering over that first list item, because the sub menu was a child of it.
In general, I use display:block/display:none to toggle hiding and showing of items, rather than visibility. Typically the use case is that you want the element completely hidden from the page, and elements around it to reflow, and the display property will do that for you.
I have a relatively simple menu bar in HTML/CSS. Everything seems to be working fine, but when the browser window is sufficiently narrow, all the items on the nav bar disappear! I'm not sure what part of the code is doing this - I've messed around a bit with the CSS to try and fix it but I haven't had any luck so far. Any pointers or suggestions are very welcome!
An example of the issue at http://www.tomstarley.com/website/accord/pages/home.php - try making it narrower!
HTML
<head>
<link rel="stylesheet" type="text/css" href="../css/navbar.css">
<link rel="stylesheet" type="text/css" href="../css/default.css">
</head>
<body>
<div id='cssmenu'>
<ul>
<li><a href='home.php'><span>Home</span></a></li>
<li class='has-sub'><a href='aboutus.php'><span>About Us</span></a>
<ul>
<li><a href='aboutus_ethos.php'><span>Ethos</span></a>
</li>
<li><a href='aboutus_mediator.php'><span>Mediator</span></a>
</li>
<li><a href='aboutus_testimonials.php'><span>Testimonials</span></a>
</li>
</ul>
</li>
<li class='has-sub'><a href='mediation.php'><span>Mediation</span></a>
<ul>
<li><a href='mediation_whatismediation.php'><span>What is Mediation?</span></a>
</li>
<li><a href='mediation_howdoesitwork.php'><span>How does it work?</span></a>
</li>
<li><a href='mediation_divorce.php'><span>Divorce</span></a>
</li>
<li><a href='mediation_cohabitants.php'><span>Cohabitants</span></a>
</li>
<li><a href='mediation_children.php'><span>Children</span></a>
</li>
<li><a href='mediation_finance.php'><span>Finance</span></a>
</li>
</ul>
</li>
<li class='has-sub'><a href='costs.php'><span>Costs</span></a>
<ul>
<li><a href='costs_fees.php'><span>Fees</span></a>
</li>
<li><a href='costs_packages.php'><span>Packages</span></a>
</li>
</ul>
</li>
<li><a href='faqs.php'><span>FAQs</span></a></li>
<li class='last'><a href='links.php'><span>Links</span></a></li>
</ul>
</div>
</body>
CSS
#cssmenu {
position: relative;
height: 22px;
background: #009ACD;
width: 100%;
}
#cssmenu ul {
list-style: none;
padding: 0;
margin: 0;
line-height: 1;
}
#cssmenu > ul {
position: relative;
display: block;
background: #009ACD;
height: 32px;
width: auto;
z-index: 500;
}
#cssmenu > ul > li {
display: block;
position: relative;
float: left;
margin: 0;
padding: 0;
}
#cssmenu > ul > #menu-button {
display: none;
}
#cssmenu ul li a {
display: block;
font-family: Helvetica, sans-serif;
text-decoration: none;
}
#cssmenu > ul > li > a {
font-size: 14px;
font-weight: bold;
padding: 15px 20px;
color: #FFFFFF;
text-transform: uppercase;
-webkit-transition: color 0.25s ease-out;
-moz-transition: color 0.25s ease-out;
-ms-transition: color 0.25s ease-out;
-o-transition: color 0.25s ease-out;
transition: color 0.25s ease-out;
}
#cssmenu > ul > li.has-sub > a {
padding-right: 32px;
}
#cssmenu > ul > li:hover > a {
color: #000000;
}
#cssmenu li.has-sub::after {
display: block;
content: '';
position: absolute;
width: 0;
height: 0;
}
#cssmenu > ul > li.has-sub::after {
right: 10px;
top: 20px;
border: 5px solid transparent;
border-top-color: #FFFFFF;
}
#cssmenu > ul > li:hover::after {
border-top-color: #000000;
}
#indicatorContainer {
position: absolute;
height: 12px;
width: 100%;
bottom: 0px;
overflow: hidden;
z-index: -1;
}
#pIndicator {
position: absolute;
height: 0;
width: 100%;
border: 12px solid transparent;
border-top-color: #2b2f3a;
z-index: -2;
-webkit-transition: left .25s ease;
-moz-transition: left .25s ease;
-ms-transition: left .25s ease;
-o-transition: left .25s ease;
transition: left .25s ease;
}
#cIndicator {
position: absolute;
height: 0;
width: 100%;
border: 12px solid transparent;
border-top-color: #2b2f3a;
top: -12px;
right: 100%;
z-index: -2;
}
#cssmenu ul ul {
position: absolute;
left: -9999px;
top: 70px;
opacity: 0;
-webkit-transition: opacity .3s ease, top .25s ease;
-moz-transition: opacity .3s ease, top .25s ease;
-ms-transition: opacity .3s ease, top .25s ease;
-o-transition: opacity .3s ease, top .25s ease;
transition: opacity .3s ease, top .25s ease;
z-index: 1000;
}
#cssmenu ul ul ul {
top: 37px;
padding-left: 5px;
}
#cssmenu ul ul li {
position: relative;
}
#cssmenu > ul > li:hover > ul {
left: auto;
top: 44px;
opacity: 1;
}
#cssmenu ul ul li:hover > ul {
left: 170px;
top: 0;
opacity: 1;
}
#cssmenu ul ul li a {
width: 130px;
border-bottom: 1px solid #eee;
padding: 10px 20px;
font-size: 12px;
color: #FFFFFF;
background: #009ACD;
-webkit-transition: all .35s ease;
-moz-transition: all .35s ease;
-ms-transition: all .35s ease;
-o-transition: all .35s ease;
transition: all .35s ease;
}
#cssmenu ul ul li:hover > a {
background: #f6f6f6;
color: #000000;
}
#cssmenu ul ul li:last-child > a,
#cssmenu ul ul li.last > a {
border-bottom: 0;
}
.submenuArrow {
border: 6px solid transparent;
width: 0;
height: 0;
border-bottom-color: #fff;
position: absolute;
top: -12px;
}
#cssmenu ul ul li.has-sub::after {
border: 4px solid transparent;
border-left-color: #9ea2a5;
right: 10px;
top: 12px;
-moz-transition: all .2s ease;
-ms-transition: all .2s ease;
-o-transition: all .2s ease;
transition: all .2s ease;
-webkit-transition: -webkit-transform 0.2s ease, right 0.2s ease;
}
#cssmenu ul ul li.has-sub:hover::after {
border-left-color: #fff;
right: -5px;
-webkit-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
#media all and (max-width: 800px), only screen and (-webkit-min-device-pixel-ratio: 2) and (max-width: 1024px), only screen and (min--moz-device-pixel-ratio: 2) and (max-width: 1024px), only screen and (-o-min-device-pixel-ratio: 2/1) and (max-width: 1024px), only screen and (min-device-pixel-ratio: 2) and (max-width: 1024px), only screen and (min-resolution: 192dpi) and (max-width: 1024px), only screen and (min-resolution: 2dppx) and (max-width: 1024px) {
#cssmenu {
width: auto;
}
#cssmenu ul {
width: auto;
}
#cssmenu .submenuArrow,
#cssmenu #indicatorContainer {
display: none;
}
#cssmenu > ul {
height: auto;
display: block;
}
#cssmenu > ul > li {
float: none;
}
#cssmenu li,
#cssmenu > ul > li {
display: none;
}
#cssmenu ul ul,
#cssmenu ul ul ul,
#cssmenu ul > li:hover > ul,
#cssmenu ul ul > li:hover > ul {
position: relative;
left: auto;
top: auto;
opacity: 1;
padding-left: 0;
}
#cssmenu ul .has-sub::after {
display: none;
}
#cssmenu ul li a {
padding: 12px 20px;
}
#cssmenu ul ul li a {
border: 0;
background: none;
width: auto;
padding: 8px 35px;
}
#cssmenu ul ul li:hover > a {
background: none;
color: #8c9195;
}
#cssmenu ul ul ul a {
padding: 8px 50px;
}
#cssmenu ul ul ul ul a {
padding: 8px 65px;
}
#cssmenu ul ul ul ul ul a {
padding: 8px 80px;
}
#cssmenu ul ul ul ul ul ul a {
padding: 8px 95px;
}
#cssmenu > ul > #menu-button {
display: block;
cursor: pointer;
}
#cssmenu #menu-button > a {
padding: 14px 20px;
}
#cssmenu ul.open li,
#cssmenu > ul.open > li {
display: block;
}
#cssmenu > ul.open > li#menu-button > a {
color: #fff;
border-bottom: 1px solid rgba(150, 150, 150, 0.1);
}
#cssmenu #menu-button::after {
display: block;
content: '';
position: absolute;
height: 3px;
width: 22px;
border-top: 2px solid #7a8189;
border-bottom: 2px solid #7a8189;
right: 20px;
top: 15px;
}
#cssmenu #menu-button::before {
display: block;
content: '';
position: absolute;
height: 3px;
width: 22px;
border-top: 2px solid #7a8189;
right: 20px;
top: 25px;
}
#cssmenu ul.open #menu-button::after,
#cssmenu ul.open #menu-button::before {
border-color: #fff;
}
}
You have a media query pointing to a max-width of 800px that makes the main menu's unordered list disappear with a display: none.
Basically, the media query is making the browser load a new CSS display value on the menu's list items. By making an element´s display equal to none you are telling the browser stop displaying it, thus making this element disappear.
#media all and (max-width: 800px), only screen and (-webkit-min-device-pixel-ratio: 2) and (max-width: 1024px), only screen and (min--moz-device-pixel-ratio: 2) and (max-width: 1024px), only screen and (-o-min-device-pixel-ratio: 2/1) and (max-width: 1024px), only screen and (min-device-pixel-ratio: 2) and (max-width: 1024px), only screen and (min-resolution: 192dpi) and (max-width: 1024px), only screen and (min-resolution: 2dppx) and (max-width: 1024px) {
#cssmenu li, #cssmenu > ul > li{
display: none
}
By removing this line you will get an horizontal menu stretching along the site's full width, which I assume is what you are looking for, is it not?
If you want to understand more about media queries and how they work you can read about it on this excelent post on the subject - https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries
Line 198 in navbar.css. You are hinding the li's when the screen is less than 800px
#cssmenu li, #cssmenu > ul > li {
display: none;
}
in navbar.css
#cssmenu li, #cssmenu > ul > li {
display: none;
}
I have a dropdown menu that is generated from WordPress so I do not want to change the HTML of it. i can change the CSS as needed though and I pretty much have ot working as I need it with the exception of an alignment issue with my dropdown menu.
Google Chrome
FireFox
Internet Explorer
From the images above you can see that IE and FIreFox display it the same but Chrome is always different from the 2. My Goal is to get this box to align perfectly with the right of the menu button and then get it to look that way in all 3 of these browsers.
I have extracted the HTML and CSS into a JSFiddle page for testing and playing around with here...
Code View: http://jsfiddle.net/jasondavis/hAb4k/
Full View for viewing the menu: http://jsfiddle.net/jasondavis/hAb4k/embedded/result/
My HTML
<nav id="head-nav-menu" class="nav-main" role="navigation" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement">
<ul id="nav" class="nav nav-pills">
<li class="active menu-home">
Home
</li>
<li class="menu-about">
About
</li>
<li class="menu-projects">
Projects
</li>
<li class="menu-blog">
Blog
</li>
<li class="dropdown menu-services">
<a class="dropdown-toggle" data-toggle="dropdown" data-target="#" href="/services/">Services <b class="caret"></b></a>
<ul class="dropdown-menu">
<li class="menu-consulting">Consulting</li>
<li class="menu-magento-development">
Magento Development
</li>
<li class="menu-wordpress-development">
WordPress Development
</li>
<li class="menu-sugarcrm-development">
SugarCRM Development
</li>
<li class="menu-web-development">
Web Development
</li>
<li class="menu-seo">
SEO
</li>
</ul>
</li>
<li class="menu-contact">
Contact
</li>
</ul>
</nav>
CSS
body{
background: #40C8F4 !important;
}
nav ul, nav ol {
list-style: none;
list-style-image: none;
}
#head-nav-menu{
float: right;
margin-top: 29px;
}
#head-nav-menu li {
float: left;
position: relative;
padding: 0 2px 0 2px;
}
.nav a {
font-family: 'arial';
font-size: 18px;
padding: 8px 18px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
white-space: nowrap;
color: #fff;
opacity: 0.9;
letter-spacing: 1px;
text-decoration: none;
}
.menu-contact a {
border: 2px solid #FFF;
padding: 8px 18px;
transition: 0.05s linear;
-moz-transition: 0.05s linear;
-webkit-transition: 0.05s linear;
}
.nav .menu-contact a:hover {
background-color: #FFF;
color: #797979;
}
#nav ul a {
font-weight: 100;
}
.nav a:hover,
.nav > .active a {
opacity: 1;
background-color: #3DBCE6;
}
.nav > .active li a {
background-color: inherit;
}
.tinynav {
display: none;
width: 100%;
margin-top: .5em;
margin-bottom: .6em;
}
.nav li.button a {
background-color: rgba(255, 255, 255, 0.1);
border: 2px solid #FFF;
border-radius: 4px;
margin-top: 5px;
padding: 8px 18px;
font-family: 'ProximaNova-bold', Helvetica, Arial, sans-serif;
font-weight: normal;
margin-left: 16px;
color: #FFF !important;
}
.nav li.button a:hover {
background-color: #FFF;
opacity: 1;
color: #444 !important;
}
/* ==========================================================================
Main Container General Layout Styles
========================================================================== */
.header-container header {
padding-top: 13px;
padding-bottom: 18px;
}
/* Navigation > Dropdown Menus */
#nav .dropdown-menu,
#nav .children {
display: none;
padding: 0;
position: absolute;
z-index: 99999;
border: 1px solid #86DEFC;
width: 333%;
/*right: 8px;*/
left: -239%;
top: 23px;
background-color: #F2F9FC;
}
#nav .dropdown-menu li {
width: 195px;
float: left;
display: inline-block;
/*width: 50%;*/
}
.nav .dropdown-menu a {
color: #030303;
}
#nav li:hover > ul,
#nav ul li:hover > ul,
.dropdown:hover > ul {
display: inline-block;
-webkit-animation: fadeDown 250ms ease;
-moz-animation: fadeDown 250ms ease;
-ms-animation: fadeDown 250ms ease;
-o-animation: fadeDown 250ms ease;
animation: fadeDown 250ms ease;
background-color: #fff;
color: #000;
border: 1px solid #E9E9E9;
border-top: none;
}
#nav .dropdown-menu ul,
#nav .children ul {
left: 99.75%;
top: -1px;
}
#nav ul li,
#nav ul ul li {
margin-left: 0;
}
#nav ul li:first-child,
#nav ul ul li:first-child {
border-top: none;
}
#nav ul a,
#nav ul ul a {
font-size: 14px;
line-height: 21px;
text-align: left;
padding: 10px;
display: inline-block;
min-width: 125px;
border-bottom: none;
margin-bottom: 0 !important;
width: 100%;
letter-spacing: 1px;
font-family: arial;
}
#nav ul a:hover,
#nav ul ul a:hover {
color: #098EB9 !important;
background: none;
}
#nav ul ul.dropdown-menu a:hover {
width: 100%;
color: #63E924 !important;
border-bottom: none;
}
#nav li.current_page_item ul a,
#nav li.current-menu-parent ul a,
#nav li.current_page_parent ul a {
color: #000;
font-weight: 700;
}
#nav ul li.current-menu-item a {
color: #e9242e !important;
}
#head-nav-menu .nav li:hover a.dropdown-toggle {
background: #fff;
color: #000;
opacity: 1;
border-right: 1px solid #E7E7E7;
}
.nav .dropdown a:hover {
opacity: 1;
background-color: #fff;
}
#nav .dropdown-menu li:hover {
background: #F8F8F8;
}
Give display: block to .nav a
then remove left: 239% of #nav .dropdown-menu and give right: 2px and top: 38px to it.
Here is the edited demo for it.
http://jsfiddle.net/hAb4k/3/