I would to make my navbar on center. Tried this:
#menu {
position: relative;
height: 44px;
width: auto;
padding-left:165px;
}
But, this code does not works on large screen or zoom out. And I've tried
margin-left:auto;
margin-right:auto;
Here is my full navbar codes
#menu {
position: relative;
height: 44px;
width: auto;
margin: 0px auto;
}
#menu ul {
list-style: none;
padding: 0;
margin: 0;
line-height: 1;
}
#menu > ul {
position: relative;
display: block;
background: -moz-linear-gradient(#4F93EF, #1162CB);
background: -o-linear-gradient(#4F93EF, #1162CB);
background: -webkit-linear-gradient(#4F93EF, #1162CB);
/*border-radius: 15px 15px 0px 0px;
-moz-border-radius: 15px 15px 0px 0px;
-webkit-border: 15px 15px 0px 0px;*/
width: 1020px;
z-index: 500;
}
#menu:after,
#menu > ul:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
#menu.align-right > ul > li {
float: right;
}
#menu.align-center ul {
text-align: center;
}
#menu.align-center ul ul {
text-align: left;
}
#menu > ul > li {
display: inline-block;
position: relative;
margin: 0;
padding: 0;
}
#menu > ul > #menu-button {
display: none;
}
#menu ul li a {
display: block;
font-family:Geneva, Arial, Helvetica, sans-serif;
text-decoration: none;
}
#menu > 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;
}
#menu > ul > li.has-sub > a {
padding-right: 32px;
}
#menu > ul > li:hover > a {
color: #b6b6b6;
}
#menu li.has-sub::after {
display: block;
content: "";
position: absolute;
width: 0;
height: 0;
}
#menu > ul > li.has-sub::after {
right: 15px;
top: 20px;
border: 5px solid transparent;
border-top-color: #ffffff;
}
#menu > ul > li:hover::after {
border-top-color: #b6b6b6;
}
#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: #0053a6;
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: #0053a6;
top: -12px;
right: 100%;
z-index: -2;
}
#menu 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;
}
#menu ul ul ul {
top: 37px;
padding-left: 5px;
}
#menu ul ul li {
position: relative;
}
#menu > ul > li:hover > ul {
left: auto;
top: 44px;
opacity: 1;
}
#menu.align-right > ul > li:hover > ul {
left: auto;
right: 0;
opacity: 1;
}
#menu ul ul li:hover > ul {
left: 190px;
top: 0;
opacity: 1;
}
#menu.align-right ul ul li:hover > ul {
left: auto;
right: 190px;
top: 0;
opacity: 1;
padding-right: 5px;
}
#menu ul ul li a {
width: 150px; /*ukuran kotak*/
border-bottom: 1px solid #eeeeee;
padding: 10px 20px;
font-size: 12px;
font-weight:bold;
color: #ffffff;
background: #006ad4;
-webkit-transition: all .35s ease;
-moz-transition: all .35s ease;
-ms-transition: all .35s ease;
-o-transition: all .35s ease;
transition: all .35s ease;
}
#menu.align-right ul ul li a {
text-align: right;
}
#menu ul ul li:hover > a {
background: #0160bf;
color: #b6b6b6;
}
#menu ul ul li:last-child > a,
#menu ul ul li.last > a {
border-bottom: 0;
}
#menu > ul > li > ul::after {
content: '';
border: 6px solid transparent;
width: 0;
height: 0;
border-bottom-color: #b6b6b6;
position: absolute;
top: -12px;
left: 30px;
}
#menu.align-right > ul > li > ul::after {
left: auto;
right: 30px;
}
#menu ul ul li.has-sub::after {
border: 4px solid transparent;
border-left-color: #b6b6b6;
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;
}
#menu.align-right ul ul li.has-sub::after {
border-left-color: transparent;
border-right-color: #b6b6b6;
right: auto;
left: 10px;
}
#menu ul ul li.has-sub:hover::after {
border-left-color: #b6b6b6;
right: -5px;
-webkit-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
#menu.align-right ul ul li.has-sub:hover::after {
border-right-color: #b6b6b6;
border-left-color: transparent;
left: -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) {
#menu {
width: auto;
}
#menu.align-center ul {
text-align: left;
}
#menu.align-right > ul > li {
float: none;
}
#menu ul {
width: auto;
}
#menu .submenuArrow,
#menu #indicatorContainer {
display: none;
}
#menu > ul {
height: auto;
display: block;
}
#menu > ul > li {
float: none;
}
#menu li,
#menu > ul > li {
display: none;
}
#menu ul ul,
#menu ul ul ul,
#menu ul > li:hover > ul,
#menu ul ul > li:hover > ul,
#menu.align-right ul ul,
#menu.align-right ul ul ul,
#menu.align-right ul > li:hover > ul,
#menu.align-right ul ul > li:hover > ul {
position: relative;
left: auto;
top: auto;
opacity: 1;
padding-left: 0;
padding-right: 0;
right: auto;
}
#menu ul .has-sub::after {
display: none;
}
#menu ul li a {
padding: 12px 20px;
}
#menu ul ul li a {
border: 0;
background: none;
width: auto;
padding: 8px 35px;
}
#menu.align-right ul ul li a {
text-align: left;
}
#menu ul ul li:hover > a {
background: none;
color: #b6b6b6;
}
#menu ul ul ul a {
padding: 8px 50px;
}
#menu ul ul ul ul a {
padding: 8px 65px;
}
#menu ul ul ul ul ul a {
padding: 8px 80px;
}
#menu ul ul ul ul ul ul a {
padding: 8px 95px;
}
#menu > ul > #menu-button {
display: block;
cursor: pointer;
}
#menu #menu-button > a {
padding: 14px 20px;
}
#menu ul.open li,
#menu > ul.open > li {
display: block;
}
#menu > ul.open > li#menu-button > a {
color: #fff;
border-bottom: 1px solid rgba(150, 150, 150, 0.1);
}
#menu ul ul::after {
display: none;
}
#menu #menu-button::after {
display: block;
content: '';
position: absolute;
height: 3px;
width: 22px;
border-top: 2px solid #ffffff;
border-bottom: 2px solid #ffffff;
right: 20px;
top: 15px;
}
#menu #menu-button::before {
display: block;
content: '';
position: absolute;
height: 3px;
width: 22px;
border-top: 2px solid #ffffff;
right: 20px;
top: 25px;
}
#menu ul.open #menu-button::after,
#menu ul.open #menu-button::before {
border-color: #fff;
}
}
I've tried margin-left auto, margin-right auto and margin 0px auto
Still does not work, any solution guys?
Need to fix the width of the parent tag and set the style="margin:0px auto;"
Your use of margin-left and margin-right is incorrect, it should be:
margin-left:auto;
margin-right:auto;
Try to use left and right with auto
#menu {
position: relative;
height: 44px;
width: auto;
margin-left:auto;
margin-right:auto;
float:none !important;
}
try the following:
#menu {
position: relative;
height: 44px;
width: 500px;
right: 0;
left: 0;
margin-right: auto;
margin-left: auto;
background-color: red;
color: white;
display: block;
}
PS: try the position as absolute or fixed also instead of relative.
Related
I have two bootstrap menus which collapse at certain max-widths leaving me with the following results. I am trying to get the sub menu items on the blue navigation bar to overflow in the same way that they do on the purple. Any suggestions?
Blue menu
Purple menu
Purple Menu's CSS
nav {
background-color: #603180;
z-index: 10000;
position: relative;
}
#toggle {
display: none;
}
nav ul li {
display: inline;
list-style: none;
}
#cssmenu .menu-main-nav-menu-container {
background: #603180;
margin: 0;
width: auto;
padding: 0;
line-height: 1;
display: block;
position: relative;
}
#cssmenu .menu-main-nav-menu-container ul .current-menu-item {
background-color: #00337e;
}
#cssmenu .menu-main-nav-menu-container ul .current-menu-item ul .current-menu-item {
background-color: #ffffff;
}
#cssmenu .menu-main-nav-menu-container ul li ul .current-menu-item a:link {
background-color: #ffffff;
font-weight:700;
}
#cssmenu .menu-main-nav-menu-container .current-page-parent {
background-color: #00337e;
}
#cssmenu .menu-main-nav-menu-container .sub-menu .current-page-parent {
background-color: #ffffff;
}
#cssmenu .menu-main-nav-menu-container ul {
list-style: none;
margin: 0;
padding: 0;
display: block;
text-align:left;
}
#cssmenu .menu-main-nav-menu-container ul li {
margin: 0;
padding: 0;
display: block;
position: relative;
}
#cssmenu .menu-main-nav-menu-container ul li a {
text-decoration: none;
display: block;
margin: 0;
-webkit-transition: color .2s ease;
-moz-transition: color .2s ease;
-ms-transition: color .2s ease;
-o-transition: color .2s ease;
transition: color .2s ease;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#cssmenu .menu-main-nav-menu-container ul li ul {
position: absolute;
left: -9999px;
top: auto;
}
#cssmenu .menu-main-nav-menu-container ul li ul li {
max-height: 0;
position: absolute;
-webkit-transition: max-height 0.4s ease-out;
-moz-transition: max-height 0.4s ease-out;
-ms-transition: max-height 0.4s ease-out;
-o-transition: max-height 0.4s ease-out;
transition: max-height 0.4s ease-out;
background: #ffffff;
}
#cssmenu .menu-main-nav-menu-container.align-right ul li ul li.has-sub:after {
right: auto;
left: 15px;
}
#cssmenu .menu-main-nav-menu-container ul li ul li a {
color: #00337e !important;
letter-spacing: 0;
display: block;
padding: 5px 25px !important;
background-color: #ffffff;
}
#cssmenu .menu-main-nav-menu-container ul li ul li:hover {
background-color: #603180;
color: #ffffff;
-webkit-transition: all 0.15s linear;
-moz-transition: all 0.15s linear;
-o-transition: all 0.15s linear;
-ms-transition: all 0.15s linear;
transition: all 0.15s linear;
}
#cssmenu .menu-main-nav-menu-container ul li ul li:hover > a,
#cssmenu .menu-main-nav-menu-container ul li ul li.active > a {
color: #ffffff !important;
}
#cssmenu .menu-main-nav-menu-container ul li ul li:hover:after,
#cssmenu .menu-main-nav-menu-container ul li ul li.active:after {
background: #4cb6ea;
}
#cssmenu .menu-main-nav-menu-container ul li ul li:hover > ul {
left: 100%;
top: 0;
}
#cssmenu .menu-main-nav-menu-container ul li ul li:hover > ul > li {
max-height: 72px;
position: relative;
}
#cssmenu .menu-main-nav-menu-container > ul > li {
float: left;
}
#cssmenu .menu-main-nav-menu-container.align-center > ul > li {
float: none;
display: inline-block;
}
#cssmenu .menu-main-nav-menu-container.align-center > ul {
text-align: center;
font-size: 0;
}
#cssmenu .menu-main-nav-menu-container.align-center ul ul {
text-align: left;
}
#cssmenu .menu-main-nav-menu-container.align-right > ul {
float: right;
}
#cssmenu .menu-main-nav-menu-container.align-right > ul > li:hover > ul {
left: auto;
right: 0;
}
#cssmenu .menu-main-nav-menu-container.align-right ul ul li:hover > ul {
right: 100%;
left: auto;
}
#cssmenu .menu-main-nav-menu-container.align-right ul ul li a {
text-align: right;
}
#cssmenu .menu-main-nav-menu-container > ul > li:after {
content: "";
display: block;
position: absolute;
width: 100%;
height: 0;
top: 0;
z-index: 0;
background: #00337e;
-webkit-transition: height .2s;
-moz-transition: height .2s;
-ms-transition: height .2s;
-o-transition: height .2s;
transition: height .2s;
}
#cssmenu .menu-main-nav-menu-container > ul > li.has-sub > a {
padding-right: 40px;
}
#cssmenu .menu-main-nav-menu-container > ul > li > a {
color: #ffffff;
letter-spacing: 1px;
text-transform: uppercase;
font-size: 15px;
z-index: 2;
position: relative;
}
#cssmenu .menu-main-nav-menu-container > ul > li:hover:after,
#cssmenu .menu-main-nav-menu-container > ul > li.active:after {
height: 100%;
}
#cssmenu .menu-main-nav-menu-container > ul > li:hover > a,
#cssmenu .menu-main-nav-menu-container > ul > li.active > a {
color: #ffffff;
}
#cssmenu .menu-main-nav-menu-container > ul > li:hover > a:after,
#cssmenu .menu-main-nav-menu-container > ul > li.active > a:after {
background: #ffffff;
}
#cssmenu .menu-main-nav-menu-container > ul > li:hover > a:before,
#cssmenu .menu-main-nav-menu-container > ul > li.active > a:before {
border-top-color: #ffffff;
}
#cssmenu .menu-main-nav-menu-container > ul > li:hover > ul {
left: 0;
z-index: 999;
}
#cssmenu .menu-main-nav-menu-container > ul > li:hover > ul > li {
max-height: 72px;
position: relative;
}
#cssmenu .menu-main-nav-menu-container #menu-button {
display: none;
}
#cssmenu .menu-main-nav-menu-container > ul > li > a {
display: block;
}
#cssmenu .menu-main-nav-menu-container > ul > li {
width: auto;
}
#cssmenu .menu-main-nav-menu-container > ul > li > ul {
width: 210px;
display: block;
box-shadow: 0 0 5px 2px rgba(0,0,0,.35);
}
#cssmenu .menu-main-nav-menu-container > ul > li > ul > li {
width: 210px;
display: block;
}
nav #cssmenu .menu-main-nav-menu-container ul li a:link {
font-size: 1em;
font-weight: 400;
color: #ffffff;
padding: 12px 26px;
}
nav #cssmenu .menu-main-nav-menu-container ul li a:hover {
background-color: #00337e;
-webkit-transition: all 0.15s linear;
-moz-transition: all 0.15s linear;
-o-transition: all 0.15s linear;
-ms-transition: all 0.15s linear;
transition: all 0.15s linear;
}
nav #cssmenu .menu-main-nav-menu-container ul li ul li a:hover {
background-color: #603180;
color: #ffffff;
-webkit-transition: all 0.15s linear;
-moz-transition: all 0.15s linear;
-o-transition: all 0.15s linear;
-ms-transition: all 0.15s linear;
transition: all 0.15s linear;
}
#media (max-width: 979px) {
nav {
opacity: 0.97;
}
#toggle {
display: block;
color: #ffffff;
width: 100%;
position: relative;
margin-bottom: 15px;
}
#toggle h6 {
font-size: 1.2857142857142858em;
padding-bottom: 10px;
}
#toggle:after {
top: 80%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(255, 255, 255, 0);
border-top-color: #ffffff;
border-width: 11px;
margin-left: -11px;
}
nav #cssmenu {
display: none;
}
nav h6 {
color: #ffffff;
}
nav #cssmenu .menu-main-nav-menu-container ul li ul {
z-index: 1000;
}
nav #cssmenu .menu-main-nav-menu-container ul li {
display: block;
clear: both;
text-align: center;
width: 100%;
}
Blue Menu's CSS
nav .container {
width: 100%;
font-weight: bold;
}
.navbar {
border-radius: 0px;
margin-bottom: 0px;
}
.navbar .nav li a {
-webkit-transition: all ease .3s;
-moz-transition: all ease .3s;
-o-transition: all ease .3s;
transition: all ease .3s;
}
.dropdown-menu {
border-radius: 0px;
padding: 0px;
}
.dropdown:hover .dropdown-menu,
.dropdown:focus .dropdown-menu { /*allows hover dropdown*/
display: block;
}
/*navbar .navbar-nav { == Comment out two lines ==
display: inline-block;
float: none;
}
.navbar .navbar-collapse {
text-align: center;
} == to center menu items ==*/
.navbar-default { /*navbar */
background-color: #004C99;
border-color: #004C99;
z-index: 10;
}
.navbar-default .navbar-brand { /*Company/Port name*/
color: #fff;
font-weight: 700;
text-transform: capitalize;
}
.navbar-default .navbar-brand:focus,
.navbar-default .navbar-brand:hover { /*Company/Port name hover*/
color: #fff;
}
.navbar-default .navbar-nav li a { /*navbar links*/
color: #fff;
}
.navbar-default .navbar-nav li a:focus,
.navbar-default .navbar-nav li a:hover { /*navbar links hover*/
color: #fff;
background-color: #00337e;
transition: color 0.33s ease-in-out;
}
.dropdown-menu li a { /*Dropdown list*/
color: #00337e !important;
width: 170px;
padding: 5px 25px;
text-transform: capitalize;
}
.dropdown-menu li a:hover { /*Dropdown list hover*/
color: #fff !important;
}
.navbar-default .navbar-nav>.open>a,
.navbar-default .navbar-nav>.open>a:focus,
.navbar-default .navbar-nav>.open>a:hover { /*Dropdown open button*/
background-color: #00337e;
color: #fff;
}
.navbar-collapse {
padding: 0px;
}
.dropdown-submenu {
position: relative;
}
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top: 0px;
margin-left: 0px;
display: none !important;
max-height: 300px;
overflow-y: auto;
overflow-x: hidden;
}
.dropdown-submenu:hover>.dropdown-menu {
display: block !important;
}
.dropdown-submenu>a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 5px 0 5px 5px;
border-left-color: #ccc;
margin-top: 4px;
margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
border-left-color: #fff;
}
.dropdown-submenu.pull-left {
float: none;
}
button.navbar-toggle {
padding-bottom: 9px !important;
}
you're going to need to remove the padding and width constraints on your nav parent elements. As you can see in this fiddle, there children extend the width of the nav with everything at 100% width and a max width on the parent element (if you need it) to constrain the menu.
http://jsfiddle.net/calebswank/1mb4n8db/
nav {
width: 100%;
max-width: 600px;
background: rgba(0, 0, 0, .1);
padding: 0;
}
I'm trying to align a menu on the center. The only problem is that it's a responsive menu and it shrunks ugly when in mobile resolution.
I tried with text-align=center in the div, I tried putting it inside a table and about everything I could find online, so I'm guessing it's something I'm doing wrong at this point.
Here is the actual menu:
<div id='cssmenu'>
<ul>
<li class="active"></img> ACASÄ‚</li>
<li class='has-sub'></img> PRODUSE
<ul>
<li class='has-sub'><a href='#'>Product 1</a>
<ul>
<li><a href='#'>Sub Product</a></li>
<li><a href='#'>Sub Product</a></li>
</ul>
</li>
<li class='has-sub'><a href='#'>Product 2</a>
<ul>
<li><a href='#'>Sub Product</a></li>
<li><a href='#'>Sub Product</a></li>
</ul>
</li>
</ul>
</li>
<li></img> CONTACT</li>
</ul>
</div>
Nothing hew there, but here's the 2 mile long menu css.
I'm sure I didn't have to post all the following css story, but perhaps it's something I'm overlooking.
#cssmenu,
#cssmenu ul,
#cssmenu ul li,
#cssmenu ul li a,
#cssmenu #menu-button {
margin: 0;
padding: 0;
border: 0;
list-style: none;
line-height: 1;
display: block;
position: relative;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#cssmenu:after,
#cssmenu > ul:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
#cssmenu #menu-button {
display: none;
}
#cssmenu {
width: auto;
font-family: 'Open Sans', sans-serif;
line-height: 1;
background: #ffffff;
}
#menu-line {
position: absolute;
top: 0;
left: 0;
height: 3px;
/*background: #009ae1;*/
background: #008000;
-webkit-transition: all 0.25s ease-out;
-moz-transition: all 0.25s ease-out;
-ms-transition: all 0.25s ease-out;
-o-transition: all 0.25s ease-out;
transition: all 0.25s ease-out;
}
#cssmenu > ul > li {
float: left;
}
#cssmenu.align-center > ul {
font-size: 0;
text-align: center;
}
#cssmenu.align-center > ul > li {
display: inline-block;
float: none;
}
#cssmenu.align-center ul ul {
text-align: left;
}
#cssmenu.align-right > ul > li {
float: right;
}
#cssmenu.align-right ul ul {
text-align: right;
}
#cssmenu > ul > li > a {
padding: 20px;
font-size: 20px;
text-decoration: none;
text-transform: uppercase;
color: #000000;
-webkit-transition: color .2s ease;
-moz-transition: color .2s ease;
-ms-transition: color .2s ease;
-o-transition: color .2s ease;
transition: color .2s ease;
}
#cssmenu > ul > li:hover > a,
#cssmenu > ul > li.active > a {
/*color: #009ae1;*/
color: #008000;
}
#cssmenu > ul > li.has-sub > a {
padding-right: 25px;
}
#cssmenu > ul > li.has-sub > a::after {
position: absolute;
top: 21px;
right: 10px;
width: 4px;
height: 4px;
border-bottom: 1px solid #000000;
border-right: 1px solid #000000;
content: "";
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transition: border-color 0.2s ease;
-moz-transition: border-color 0.2s ease;
-ms-transition: border-color 0.2s ease;
-o-transition: border-color 0.2s ease;
transition: border-color 0.2s ease;
}
#cssmenu > ul > li.has-sub:hover > a::after {
/*border-color: #009ae1;*/
border-color: #008000;
}
#cssmenu ul ul {
position: absolute;
left: -9999px;
}
#cssmenu li:hover > ul {
left: auto;
}
#cssmenu.align-right li:hover > ul {
right: 0;
}
#cssmenu ul ul ul {
margin-left: 100%;
top: 0;
}
#cssmenu.align-right ul ul ul {
margin-left: 0;
margin-right: 100%;
}
#cssmenu ul ul li {
height: 0;
-webkit-transition: height .2s ease;
-moz-transition: height .2s ease;
-ms-transition: height .2s ease;
-o-transition: height .2s ease;
transition: height .2s ease;
}
#cssmenu ul li:hover > ul > li {
height: 32px;
}
#cssmenu ul ul li a {
padding: 10px 20px;
width: 160px;
font-size: 12px;
background: #333333;
text-decoration: none;
color: #dddddd;
-webkit-transition: color .2s ease;
-moz-transition: color .2s ease;
-ms-transition: color .2s ease;
-o-transition: color .2s ease;
transition: color .2s ease;
}
#cssmenu ul ul li:hover > a,
#cssmenu ul ul li a:hover {
color: #ffffff;
}
#cssmenu ul ul li.has-sub > a::after {
position: absolute;
top: 13px;
right: 10px;
width: 4px;
height: 4px;
border-bottom: 1px solid #dddddd;
border-right: 1px solid #dddddd;
content: "";
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transition: border-color 0.2s ease;
-moz-transition: border-color 0.2s ease;
-ms-transition: border-color 0.2s ease;
-o-transition: border-color 0.2s ease;
transition: border-color 0.2s ease;
}
#cssmenu.align-right ul ul li.has-sub > a::after {
right: auto;
left: 10px;
border-bottom: 0;
border-right: 0;
border-top: 1px solid #dddddd;
border-left: 1px solid #dddddd;
}
#cssmenu ul ul li.has-sub:hover > a::after {
border-color: #ffffff;
}
#media all and (max-width: 768px), 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: 100%;
}
#cssmenu ul {
width: 100%;
display: none;
}
#cssmenu.align-center > ul,
#cssmenu.align-right ul ul {
text-align: left;
}
#cssmenu ul li,
#cssmenu ul ul li,
#cssmenu ul li:hover > ul > li {
width: 100%;
height: auto;
border-top: 1px solid rgba(120, 120, 120, 0.15);
}
#cssmenu ul li a,
#cssmenu ul ul li a {
width: 100%;
}
#cssmenu > ul > li,
#cssmenu.align-center > ul > li,
#cssmenu.align-right > ul > li {
float: none;
display: block;
}
#cssmenu ul ul li a {
padding: 20px 20px 20px 30px;
font-size: 12px;
color: #000000;
background: none;
}
#cssmenu ul ul li:hover > a,
#cssmenu ul ul li a:hover {
color: #000000;
}
#cssmenu ul ul ul li a {
padding-left: 40px;
}
#cssmenu ul ul,
#cssmenu ul ul ul {
position: relative;
left: 0;
right: auto;
width: 100%;
margin: 0;
}
#cssmenu > ul > li.has-sub > a::after,
#cssmenu ul ul li.has-sub > a::after {
display: none;
}
#menu-line {
display: none;
}
#cssmenu #menu-button {
display: block;
padding: 20px;
color: #000000;
cursor: pointer;
font-size: 12px;
text-transform: uppercase;
}
#cssmenu #menu-button::after {
content: '';
position: absolute;
top: 20px;
right: 20px;
display: block;
width: 15px;
height: 2px;
background: #000000;
}
#cssmenu #menu-button::before {
content: '';
position: absolute;
top: 25px;
right: 20px;
display: block;
width: 15px;
height: 3px;
border-top: 2px solid #000000;
border-bottom: 2px solid #000000;
}
#cssmenu .submenu-button {
position: absolute;
z-index: 10;
right: 0;
top: 0;
display: block;
border-left: 1px solid rgba(120, 120, 120, 0.15);
height: 52px;
width: 52px;
cursor: pointer;
}
#cssmenu .submenu-button::after {
content: '';
position: absolute;
top: 21px;
left: 26px;
display: block;
width: 1px;
height: 11px;
background: #000000;
z-index: 99;
}
#cssmenu .submenu-button::before {
content: '';
position: absolute;
left: 21px;
top: 26px;
display: block;
width: 11px;
height: 1px;
background: #000000;
z-index: 99;
}
#cssmenu .submenu-button.submenu-opened:after {
display: none;
}
}
Here's the fiddle. I hid your drop-down and images since they aren't needed for the example. Here are the two important rules:
ul {
display: block;
text-align: center;
}
li {
display: inline-block;
}
This will now add all items from the center and create space out. Make sure to note that inline-block elements have a hidden margin (space) so if you want them right next to each other, you'll need to create a negative margin on the li.
Wrap these new rules in a min-width media query if you don't want it to mess up your mobile styling.
I have an issue related to dropdown menu that remains behind Lean Slider. Please help me how to fix this issue. I am pasting html and css code here that you see where there is a problem.
I have tried to change z-index, but nothing changed.
HTML:
<pre><div id='cssmenu'>
<ul>
<li class='has-sub'><a href='#'>About us</a>
<ul>
<li>Submenu</li>
<li>Submenu</li>
<li>Submenu</li>
<li>Submenu</li>
<li>Submenu</li>
</ul>
</li>
<li class='has-sub'><a href='#'>Programs</a>
<ul>
<li>Submenu</li>
<li class='has-sub'><a href='#'>Submenu</a>
<ul>
<li>Submenu</li>
<li>Submenu</li>
<li>Submenu</li>
<li>Submenu</li>
<li>Submenu</li>
</ul>
</li>
<li>Submenu</li>
</ul>
</li>
<li>News</li>
<li>Network</li>
<li>Press</li>
<li class='last'>Contact us</li>
</ul>
</div><code>
I am also pasting CSS code here.
<pre>#cssmenu {
position: relative;
height: auto;
background: #2b2f3a;
width: auto;
}
#cssmenu ul {
list-style: none;
padding: 0;
margin: 0;
line-height: 1;
}
#cssmenu > ul {
position: relative;
display: block;
background: #fff;
width: 100%;
z-index: 500;
}
#cssmenu:after,
#cssmenu > ul:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
#cssmenu.align-right > ul > li {
float: right;
}
#cssmenu.align-center ul {
text-align: center;
}
#cssmenu.align-center ul ul {
text-align: left;
}
#cssmenu > ul > li {
display: inline-block;
position: relative;
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: 12px;
font-weight: bold;
padding: 17px 12px;
color: #559c00;
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: #72cc00;
}
#cssmenu li.has-sub::after {
display: block;
content: "";
position: absolute;
width: 0;
height: 0;
}
#cssmenu > ul > li.has-sub::after {
right: 15px;
top: 20px;
border: 5px solid transparent;
border-top-color: #559c00;
}
#cssmenu > ul > li:hover::after {
border-top-color: #ffffff;
}
#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.align-right > ul > li:hover > ul {
left: auto;
right: 0;
opacity: 1;
}
#cssmenu ul ul li:hover > ul {
left: 210px;
top: 0;
opacity: 1;
}
#cssmenu.align-right ul ul li:hover > ul {
left: auto;
right: 170px;
top: 0;
opacity: 1;
padding-right: 5px;
}
#cssmenu ul ul li a {
width: 170px;
margin-right: 3px;
border-bottom: 1px solid #eeeeee;
padding: 10px 20px;
font-size: 12px;
color: #559c00;
font-weight:bold;
background: #fff;
-webkit-transition: all .35s ease;
-moz-transition: all .35s ease;
-ms-transition: all .35s ease;
-o-transition: all .35s ease;
transition: all .35s ease;
box-shadow: 3px 3px 8px #818181; /*shadow for CSS3 capable browsers.*/
-webkit-box-shadow: 1px 1px 5px #818181;
-moz-box-shadow: 3px 3px 8px #818181;
}
#cssmenu.align-right ul ul li a {
text-align: right;
}
#cssmenu ul ul li:hover > a {
background: #fff;
color: #72cc00;
}
#cssmenu ul ul li:last-child > a,
#cssmenu ul ul li.last > a {
}
#cssmenu > ul > li > ul::after {
content: '';
border: 6px solid transparent;
width: 0;
height: 0;
border-bottom-color: #559c00;
position: absolute;
top: -12px;
left: 30px;
}
#cssmenu.align-right > ul > li > ul::after {
left: auto;
right: 30px;
}
#cssmenu ul ul li.has-sub::after {
border: 5px 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.align-right ul ul li.has-sub::after {
border-left-color: transparent;
border-right-color: #9ea2a5;
right: auto;
left: 10px;
}
#cssmenu ul ul li.has-sub:hover::after {
border-left-color: #ffffff;
right: -5px;
-webkit-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
#cssmenu.align-right ul ul li.has-sub:hover::after {
border-right-color: #ffffff;
border-left-color: transparent;
left: -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.align-center ul {
text-align: left;
}
#cssmenu.align-right > ul > li {
float: none;
}
#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,
#cssmenu.align-right ul ul,
#cssmenu.align-right ul ul ul,
#cssmenu.align-right ul > li:hover > ul,
#cssmenu.align-right ul ul > li:hover > ul {
position: relative;
left: auto;
top: auto;
opacity: 1;
padding-left: 0;
padding-right: 0;
right: auto;
}
#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.align-right ul ul li a {
text-align: left;
}
#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 ul ul::after {
display: none;
}
#cssmenu #menu-button::after {
display: block;
content: '';
position: absolute;
height: 3px;
width: 22px;
border-top: 2px solid #559c00;
border-bottom: 2px solid #559c00;
right: 20px;
top: 15px;
}
#cssmenu #menu-button::before {
display: block;
content: '';
position: absolute;
height: 3px;
width: 22px;
border-top: 2px solid #559c00;
right: 20px;
top: 25px;
}
#cssmenu ul.open #menu-button::after,
#cssmenu ul.open #menu-button::before {
border-color: #fff;
}
}
<code>
I'll be happy if you help me how to fix this issue. Thanks in advance.
You have apply overflow:hidden for the wrapper class. For that reason it is hiding the submenus. Add the following style in your CSS, hopefully it will fix the issue.
header > div.wrapper:first-child
{
overflow:visible !important;
}
NOTE: You can try without !important keyword, if it is not working then apply it like above. Because i am not sure about the order of your CSS written.
This question already has answers here:
How do I center a container in my HTML/CSS?
(2 answers)
Closed 8 years ago.
I have a question.
How would I center a nav bar with the following code?
You can see the nav bar at mineflow.us/hitest
<div align="center"><div class="special_container last"><div class='m_html' ><style><!--#import url(http://fonts.googleapis.com/css?family=PT+Sans:400,700);#cssmenu { background: #FFFFFF; margin: 0; width: auto; padding: 0; line-height: 1; display: block; position: relative; font-family: 'PT Sans', sans-serif;}#cssmenu ul { list-style: none; margin: 0; padding: 0; display: block;}#cssmenu ul:after { content: ' '; display: block; font-size: 0; height: 0; clear: both; visibility: hidden;}#cssmenu ul li { margin: 0; padding: 0; display: block; position: relative;}#cssmenu ul li a { text-decoration: none; display: block; margin: 0; -webkit-transition: color .2s ease; -moz-transition: color .2s ease; -ms-transition: color .2s ease; -o-transition: color .2s ease; transition: color .2s ease;}#cssmenu ul li ul { position: absolute; left: -9999px; top: auto;}#cssmenu ul li ul li { max-height: 0; position: absolute; -webkit-transition: max-height 0.4s ease-out; -moz-transition: max-height 0.4s ease-out; -ms-transition: max-height 0.4s ease-out; -o-transition: max-height 0.4s ease-out; transition: max-height 0.4s ease-out; background: #2E2E2E;}#cssmenu ul li ul li.has-sub:after { display: block; position: absolute; content: ''; height: 10px; width: 10px; border-radius: 5px; background: #000000; z-index: 1; top: 13px; right: 15px;}#cssmenu ul li ul li.has-sub:before { display: block; position: absolute; content: ''; height: 0; width: 0; border: 3px solid transparent; border-left-color: #ffffff; z-index: 2; top: 15px; right: 15px;}#cssmenu ul li ul li a { font-size: 14px; font-weight: 400; text-transform: none; color: #000000; letter-spacing: 0; display: block; width: 140px; padding: 11px 10px 11px 20px;}#cssmenu ul li ul li:hover > a,#cssmenu ul li ul li.active > a { color: #4cb6ea;}#cssmenu ul li ul li:hover:after,#cssmenu ul li ul li.active:after { background: #4cb6ea;}#cssmenu ul li ul li:hover > ul { left: 170px; top: 0;}#cssmenu ul li ul li:hover > ul > li { max-height: 72px; position: relative;}#cssmenu > ul > li { float: left;}#cssmenu > ul > li:after { content: ''; display: block; position: absolute; width: 100%; height: 0; top: 0; z-index: 0; background: #2E2E2E; -webkit-transition: height .2s; -moz-transition: height .2s; -ms-transition: height .2s; -o-transition: height .2s; transition: height .2s;}#cssmenu > ul > li.has-sub > a { padding-right: 40px;}#cssmenu > ul > li.has-sub > a:after { display: block; content: ''; background: #ffffff; height: 12px; width: 12px; position: absolute; border-radius: 13px; right: 14px; top: 16px;}#cssmenu > ul > li.has-sub > a:before { display: block; content: ''; border: 4px solid transparent; border-top-color: #4cb6ea; z-index: 2; height: 0; width: 0; position: absolute; right: 16px; top: 21px;}#cssmenu > ul > li > a { color: #ffffff; padding: 15px 20px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; font-size: 14px; z-index: 2; position: relative;}#cssmenu > ul > li:hover:after,#cssmenu > ul > li.active:after { height: 100%;}#cssmenu > ul > li:hover > a,#cssmenu > ul > li.active > a { color: #000000;}#cssmenu > ul > li:hover > a:after,#cssmenu > ul > li.active > a:after { background: #000000;}#cssmenu > ul > li:hover > a:before,#cssmenu > ul > li.active > a:before { border-top-color: #ffffff;}#cssmenu > ul > li:hover > ul { left: 0;}#cssmenu > ul > li:hover > ul > li { max-height: 72px; position: relative;}#cssmenu #menu-button { display: none;}#media all and (max-width: 768px), 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 > ul { max-height: 0; overflow: hidden; -webkit-transition: max-height 0.35s ease-out; -moz-transition: max-height 0.35s ease-out; -ms-transition: max-height 0.35s ease-out; -o-transition: max-height 0.35s ease-out; transition: max-height 0.35s ease-out; } #cssmenu > ul.open { max-height: 1000px; border-top: 1px solid rgba(110, 110, 110, 0.25); } #cssmenu ul { width: 100%; } #cssmenu ul > li { float: none; } #cssmenu ul li a { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; width: 100%; padding: 12px 20px; } #cssmenu ul > li:after { display: none; } #cssmenu ul li.has-sub > a:after, #cssmenu ul li.has-sub > a:before, #cssmenu ul li ul li.has-sub:after, #cssmenu ul li ul li.has-sub:before { display: none; } #cssmenu ul li ul, #cssmenu ul li ul li ul, #cssmenu ul li ul li:hover > ul { left: 0; position: relative; } #cssmenu ul li ul li, #cssmenu ul li:hover > ul > li { max-height: 999px; position: relative; background: none; } #cssmenu ul li ul li a { padding: 8px 20px 8px 35px; color: #ffffff; width: auto; } #cssmenu ul li ul ul li a { padding: 8px 20px 8px 50px; } #cssmenu ul li ul li:hover > a { color: #000000; } #cssmenu #menu-button { display: block; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; width: 100%; padding: 15px 20px; text-transform: uppercase; font-weight: 700; font-size: 14px; letter-spacing: 1px; color: #ffffff; cursor: pointer; } #cssmenu #menu-button:after { display: block; content: ''; position: absolute; height: 3px; width: 22px; border-top: 2px solid #ffffff; border-bottom: 2px solid #ffffff; right: 20px; top: 16px; } #cssmenu #menu-button:before { display: block; content: ''; position: absolute; height: 3px; width: 22px; border-top: 2px solid #ffffff; right: 20px; top: 26px; }}--></style><div id="cssmenu"><ul><li class="last"><span style="color: rgb(125, 125, 125);"><i class="icon-home"></i> Home</span></li><li><span style="color: rgb(125, 125, 125);"><i class="icon-pencil"></i> Forum</span></li><li><span style="color: rgb(125, 125, 125);"><i class="icon-book"></i> Donate</span></li><li><span style="color: rgb(125, 125, 125);"><i class="icon-star"></i> Vote</span></li><li class="last"><span style="color: rgb(125, 125, 125);"><i class="icon-signal"></i> Status</span></li><li class="last"><span style="color: rgb(125, 125, 125);"><i class="icon-globe"></i> Staff List</span></li></ul></div><div align="center"><span style="font-weight: bold; font-family: Tahoma; font-size: 24pt; color: rgb(255, 0, 0); "><br></span></div> </div></div></div>
#cssmenu{display: inline-block;}
btw. use JSFiddle next time, please.
I'm new to coding and am having some trouble getting a drop-down menu to work.
The menu drops down correctly when my cursor hovers over its corresponding tab, but once I move the cursor down to the actual drop-down sub-categories, they disappear.
Here's the CSS for the tabs:
#cssmenu {
position: relative;
height: 44px;
background: #1d309e;
width: auto;
z-index: 100;
}
#cssmenu ul {
list-style: none;
padding: 0;
margin: 0;
line-height: 1;
}
#cssmenu > ul {
position: relative;
display: block;
background: #1d309e;
height: 32px;
width: 100%;
z-index: 99;
text-transform:lowercase;
}
#cssmenu > ul > li {
display: block;
position: relative;
float: left;
margin: 0;
padding: 0;
font-family: tahoma, "Trebuchet MS", verdana, helvetica, arial, sans-serif;
text-transform:lowercase
z-index: 100
}
#cssmenu > ul > #menu-button {
display: none;
}
#cssmenu ul li a {
display: block;
font-family: tahoma, "Trebuchet MS", verdana, helvetica, arial, sans-serif;
text-decoration: none;
text-transform:lowercase
}
#cssmenu > ul > li > a {
font-size: 15px;
padding: 0px 80px;
color: #ffffff;
-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;
text-transform:lowercase
}
#cssmenu > ul > li.has-sub > a {
padding-right: 32px;
}
#cssmenu > ul > li:hover > a {
color: #fff203;
}
#cssmenu li.has-sub::after {
display: block;
content: '';
position: absolute;
width: 0;
height: 0;
z-index: 100
}
#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: #fff203;
}
#indicatorContainer {
position: absolute;
height: 12px;
width: 100%;
bottom: 0px;
overflow: hidden;
z-index: 100;
}
#pIndicator {
position: absolute;
height: 0;
width: 100%;
border: 12px solid transparent;
border-top-color: #2b2f3a;
z-index: 100;
-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: 100;
}
#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: 100;
}
#cssmenu ul ul ul {
top: 37px;
padding-left: 5px;
}
#cssmenu ul ul li {
position: relative;
z-index: 100
}
#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: #1d309e;
background: #fff;
-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: #ffee00;
}
#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: #1d309e;
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;
z-index: 100
}
#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: #ffee00;
}
#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 #ffffff;
border-bottom: 2px solid #ffffff;
right: 20px;
top: 15px;
z-index: 100
}
#cssmenu #menu-button::before {
display: block;
content: '';
position: absolute;
height: 3px;
width: 22px;
border-top: 2px solid #ffffff;
right: 20px;
top: 25px;
z-index: 100
}
#cssmenu ul.open #menu-button::after,
#cssmenu ul.open #menu-button::before {
border-color: #fff;
}
}
And here is the HTML page I'm trying to put it on:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1' />
<link rel='stylesheet' type='text/css' href='styles.css' />
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'>
</script>
<script type='text/javascript' src='menu_jquery.js'></script>
</head>
<body>
<h1>Sugar Mule</h1>
<div id='cssmenu'>
<ul>
<li class='active'><a href='index.html'><span>Home</span></a></li>
<li class='has-sub'><a href='about.html'><span>About</span></a>
<ul>
<li><a href='why.html'><span>Why Sugar Mule?</span></a></li>
<li><a href='staff.html'><span>Staff</span></a></li>
<li class='last'><a href='contact.html'><span>Contact</span></a></li>
</ul>
</li>
<li><a href='issues.html'><span>Issues</span></a></li>
<li><a href='books.html'><span>Books</span></a></li>
<li><a href='submit.html'><span>Submit</span></a></li>
<li class='last'><a href='links.html'><span>Links</span></a></li>
</ul>
</div>
<center><img src="logo.png" alt="Logo" width="700" height="450"></center>
</body>
</html>
Thanks in advance for the help!
Because the dropdown #cssmenu > ul > li:hover > ul has a top offset of 44px.
Then you must make sure all the top level links #cssmenu > ul > li > a are atleast 44px
Heres the ammended CSS
#cssmenu > ul > li > a {
...
min-height:44px;
...
}
Fiddle: http://jsfiddle.net/Varinder/bg763/