Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Despite the fact my original account mysteriously disappeared, here's my question for the geniuses over on this site:
For a long time now, I've been 'attempting' to build a response Wordpress theme from scratch so that I can keep all of my ideas on one website. The issue happens to be with the navigation menu. I have a bit of CSS doing the justice on mobile platforms under 600px in width. However, on screens larger than 600px, I have the navbar set so that it's fixed on the webpage and maintains its position when scrolling up and down. When a screen smaller than 600px visits the site, I have it set so that the navbar should change from a fixed to relative position. Despite what I'd changed in my stylesheet, I can't seem to make the navbar switch from a fixed to relative state.
Image of the issue:
http://i.gyazo.com/9e8ac2c12d279bba4e5ff98418c9b0ed.png
When normally on the page over 600px:
http://i.gyazo.com/b54486fb441717e79ed9bd3b44ba2710.png
Here's the code. As you can see, when set to resize under 600px, the position should stay relative, but it doesn't:
.main-navigation {
position: fixed;
float: left;
width: 100%;
display: block;
clear: both;
font-family: 'Open Sans', sans-serif;
background: url('nav-bg.png') repeat center;
color: #fff;
-webkit-box-shadow: 0 3px 6px 0px black;
-moz-box-shadow: 0 3px 6px 0px black;
box-shadow: 0 3px 6px 0px black;
z-index: 999999;
}
.main-navigation ul {
list-style: none;
margin: 0;
padding-left: 0;
}
.main-navigation li {
float: left;
}
.main-navigation a {
display: block;
padding: 2.5em 3.5em;
font-size: 14px;
font-size: 1.4rem;
text-decoration: none;
line-height: 1.4em;
color: white;
color: hsl(0, 0%, 100%);
}
.main-navigation ul ul {
position: absolute;
left: 0;
z-index: 99999;
display: none;
float: left;
padding: 0;
background-image: url('nav-bg2.png');
}
.main-navigation ul ul ul {
left: 100%;
top: 0;
}
.main-navigation ul ul a {
width: 200px;
}
.main-navigation ul ul li {}
.main-navigation li:hover > a {
color: #fff;
color: hsl(0, 0%, 100%);
background: #313131;
opacity: 0.4;
}
.main-navigation ul ul :hover > a {}
.main-navigation ul ul a:hover {
background: #313131;
background: hsl(0, 0%, 19%);
}
.main-navigation ul li:hover > ul {
display: block;
}
.main-navigation ul ul li:hover > ul {
display: block;
}
.main-navigation .current_page_item > a,
.main-navigation .current-menu-item > a,
.main-navigation .current_page_item > a:hover,
.main-navigation .current-menu-item > a:hover {
-moz-box-shadow: inset 0 0 15px #000000;
-webkit-box-shadow: inset 0 0 15px #000000;
box-shadow: inset 0 0 15px #000000;
color: #fff;
}
.main-navigation .current_page_ancestor {
-moz-box-shadow: inset 0 0 15px #000000;
-webkit-box-shadow: inset 0 0 15px #000000;
box-shadow: inset 0 0 15px #000000;
}
.main-navigation ul ul .current_page_parent,
.main-navigation .current_page_parent .current_page_item > a {
-moz-box-shadow: inset 0 0 15px #000000;
-webkit-box-shadow: inset 0 0 15px #000000;
box-shadow: inset 0 0 15px #000000;
}
/* Menu Resize */
.menu-toggle {
display: none;
}
#media screen and (max-width: 600px) {
.menu-toggle {
display: block;
height: 3.75em;
padding: 0 1em;
font-weight: normal;
font-size: 14px;
font-size: 1.4rem;
text-decoration: none;
line-height: 3.75em;
color: white;
background-image: url('nav-bg2.png');
position: relative;
}
.main-navigation.toggled .nav-menu {
display: block;
border-top: 1px solid;
border-top-color: #fff;
border-top-color: hsla(0, 0%, 100%, .5);
}
.main-navigation ul {
display: none;
text-align: center;
padding-left: 0;
background-image: url('nav-bg2.png');
}
.main-navigation li {
float: none;
}
.main-navigation li a {
padding: 1.3em 2em;
}
.main-navigation li li a {
padding-left: 4em;
}
.main-navigation li li li a {
padding-left: 6em;
}
.main-navigation li:hover > a {
background: #313131;
background: hsl(0, 0%, 19%);
}
.main-navigation ul ul,
.main-navigation ul ul ul {
position: relative;
top: inherit;
left: 0;
display: block;
float: none;
background-image: url('nav-bg2.png');
}
.main-navigation ul ul a { width: 100%; }
.main-navigation ul a:hover,
.main-navigation ul ul a:hover {
background: #4d4d4d;
background: hsl(0, 0%, 30%);
}
.main-navigation .current_page_ancestor { background: inherit; }
.main-navigation ul ul .current_page_parent {
color: inherit;
background: inherit;
}
.main-navigation .current_page_item > a,
.main-navigation .current_page_item > a:hover,
.main-navigation .current_page_item li:hover,
.main-navigation .current_page_parent .current_page_item > a {
-moz-box-shadow: inset 0 0 15px #000000;
-webkit-box-shadow: inset 0 0 15px #000000;
box-shadow: inset 0 0 15px #000000;
}
}
You never set the position back to relative for .main-navigation - you do so for .menu-toggle (which I assume is your dropdown button?)
Try adding this:
#media screen and (max-width: 600px){
.main-navigation {
position: relative;
float: none;
}
}
Related
I am currently working on my nav bar. One issue I am having is that when I added 10px of padding to my main navigation .navi ul, 10px of clear space got added to all the drop down items under each menu item and I just can't figure out why. You can see this in action here: http://cbchaverhill.onedirectionconnection.com/
Here is my CSS:
.navi {
background: #222; /* Show a solid color for older browsers */
background: -moz-linear-gradient(#252525, #0a0a0a);
background: -o-linear-gradient(#252525, #0a0a0a);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#252525), to(#0a0a0a)); /* older webkit syntax */
background: -webkit-linear-gradient(#252525, #0a0a0a);
clear: both;
display: block;
float: left;
margin: 0 auto 6px;
width: 100%;
}
.navi ul {
font-size: 13px;
list-style: none;
margin: 0 0 0 -0.8125em;
padding-left: 10px;
}
.navi li {
float: left;
position: relative;
}
.navi a {
color: #eee;
display: block;
line-height: 3.333em;
padding: 0 1.2125em;
text-decoration: none;
font-weight: bold;
}
.navi ul ul {
-moz-box-shadow: 0 3px 3px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 3px 3px rgba(0,0,0,0.2);
box-shadow: 0 3px 3px rgba(0,0,0,0.2);
display: none;
float: left;
margin: 0;
position: absolute;
top: 3.333em;
left: 0;
width: 188px;
z-index: 99999;
}
.navi ul ul ul {
left: 100%;
top: 0;
}
.navi ul ul a {
background: #f9f9f9;
border-bottom: 1px dotted #ddd; color: #444;
font-size: 13px;
font-weight: normal;
height: auto;
line-height: 1.4em;
padding: 10px 10px;
width: 188px;
}
.navi li:hover > a,
.navi ul ul :hover > a,
.navi a:focus {
background: #efefef;
}
.navi li:hover > a,
.navi a:focus {
background: #f9f9f9; /* Show a solid color for older browsers */
background: -moz-linear-gradient(#f9f9f9, #e5e5e5);
background: -o-linear-gradient(#f9f9f9, #e5e5e5);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f9f9f9), to(#e5e5e5)); /* Older webkit syntax */
background: -webkit-linear-gradient(#f9f9f9, #e5e5e5);
color: #373737;
}
.navi ul li:hover > ul {
display: block;
}
.navi
.current-menu-item > a,
.navi .current-menu-ancestor > a,
.navi .current_page_item > a,
.navi .current_page_ancestor > a {
font-weight: bold;
}
Any help would be greatly appreciated!
The css you apply to the .navi ul also applies to the nested ul's.
.navi ul {
padding-left: 10px;
}
One way to resolve this:
.navi ul ul {
padding-left: 0px;
}
Or:
.navi ul {
font-size: 13px;
list-style: none;
margin: 0 0 0 0;
}
I can't get the color of my dropdown items white, someone knows how I can fix this?
My normal links needs to be black, the not active ones needs to be black, the active one needs to be white, the dropdown items needs to be white. I've got it all with that code except for the most up dropdown item.
Heres my css:
.menuitems{
line-height: 240%;
text-transform: uppercase;
}
.menuitems ul {
font-family: Arial, Verdana;
font-size: 14px;
margin: 0;
padding: 0;
}
.menuitems ul li {
display: block;
position: relative;
float: left;
}
.menuitems li ul {
display: none;
}
.menuitems ul li a {
height: 40px;
display: block;
text-decoration: none;
color: black;
border-left: 1px #D0D0D0 solid;
padding: 0px 30px 0px 30px;
}
.menuitems li > ul li a
{
color:white;
}
.menuitems ul ul li{
text-transform: none;
border-bottom: 1px #ff5c38 solid;
line-height: 380%;
}
.menuitems ul li:hover{
background: url('images/menu-background1.png') repeat-x 0 0;
}
.menuitems ul li a:hover {
height:40px;
color: white;
padding-left: 30px !important;
padding-right: 30px !important;
}
.menuitems li:hover ul {
display: block;
position: absolute;
}
.menuitems li:hover li {
float: none;
font-size: 13px;
background: #fa3423;
}
.menuitems li:hover a { }
.menuitems li:hover li a:hover {
}
/* What to do on active */
.menuitems ul li.current_page_item {
background: url('images/menu-background1.png') repeat-x 0 0;
}
.menuitems ul li.current_page_item a{
color: white;
}
.menuitems li.current_page_parent a {
color: white;
}
.menuitems li.current_page_parent {
color: white;
background: url('images/menu-background1.png') repeat-x 0 0;
}
.menuitems li:hover ul:hover a:hover{
color: white !important;
}
.menuitems ul li ul{
color: white;
}
I tried everything.. :(
Castra, I assume you're talking about the text? If you want the text to always be white, you'll need to change color: black; in .menuitems ul li a to color: white;
Here's a JSFiddle that shows it.
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I am a css newbie. I have created a menu in which there is a small space appearing between the menu and the drop down menu which caused the hover effect to break. Please help me out. Thanks
#menu, #menu ul {
margin: 0;
padding: 0;
list-style: none;
}
#menu {
width: 958px;
/*margin: 60px auto;*/
border: 1px solid #222;
background-color: #111;
background-image: linear-gradient(#444, #111);
box-shadow: 0 1px 1px #777;
}
#menu:before,
#menu:after {
content: "";
display: table;
}
#menu:after {
clear: both;
}
#menu {
zoom:1;
}
#menu li {
float: left;
/* border-right: 1px solid #222;*/
box-shadow: 1px 0 0 #444;
position: relative;
box-sizing: border-box;
width: 20%;
}
#menu a {
float: left;
padding: 11px 64px;
color: #999;
text-transform: uppercase;
text-decoration: none;
text-shadow: 0 1px 0 #000;
}
#menu li:hover > a {
color: #fafafa;
}
*html #menu li a:hover { /* IE6 only */
color: #fafafa;
}
#menu ul {
margin: 20px 0 0 0;
_margin: 0; /*IE6 only*/
opacity: 0;
visibility: hidden;
position: absolute;
top: 38px;
left: 0;
z-index: 1000000;
background: #444;
background: linear-gradient(#444, #111);
box-shadow: 0 -1px 0 rgba(255,255,255,.3);
transition: all .2s ease-in-out;
width: 100%;
}
#menu li:hover > ul {
opacity: 1;
visibility: visible;
margin: 0;
}
#menu ul ul {
top: 0;
left: 150px;
margin: 0 0 0 20px;
width:100%;
_margin: 0; /*IE6 only*/
box-shadow: -1px 0 0 rgba(255,255,255,.3);
}
#menu ul li {
float: none;
display: block;
border: 0;
_line-height: 0; /*IE6 only*/
box-shadow: 0 1px 0 #111, 0 2px 0 #666;
}
#menu ul li:last-child {
box-shadow: none;
}
#menu ul a {
padding: 10px;
width: 130px;
_height: 10px; /*IE6 only*/
display: block;
white-space: nowrap;
float: none;
text-transform: none;
}
#menu ul a:hover {
background-color: #111;
}
#menu ul li:first-child > a {
/*border-radius: 3px 3px 0 0;*/
}
#menu ul li:first-child > a:after {
content: '';
position: absolute;
left: 40px;
top: -6px;
}
#menu ul ul li:first-child a:after {
left: -6px;
top: 50%;
margin-top: -6px;
border-left: 0;
}
#menu ul li:first-child a:hover:after {
}
#menu ul ul li:first-child a:hover:after {
border-right-color: #000;
border-bottom-color: transparent;
}
#menu ul li:last-child > a {
/*border-radius: 0 0 3px 3px*/;
}
Here is the html,
<ul id="menu">
<li>About </li>
<li>Programmes<ul>
<li>Undergraduate</li>
<li>Postgraduate</li>
</ul></li>
<li>Academics</li>
<li>Research</li>
<li>Facilities</li>
</ul>
Add:
ul#menu {margin-top:-5px !important;}
The !important tag takes presence over your other margin settings for #menu ul. Adjust as needed to drop down directly below the parent menu item.
Also, if using Chrome right click any element and 'Inspect Element'. Styling will render live for you and allow you to make changes without editing, saving, uploading CSS files to see effects.
On Firefox, download Firebug for the same tools.
I am trying to install a custom menu in my Wordpress theme. I have successfully enabled the feature and embedded the menu in my layout, the only issue is that the CSS is not working for the menu.
I had a custom CSS called NAV and I also tried just copying and pasting the CSS from the Twenty Eleven them into my CSS (which is called access). But no matter what I do, the navigation style doesn't change. I'm starting to think it might be my embed code. Here it is:
<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'access', 'menu_class' => 'access' ) ); ?>
Here is the HTML that is generated:
<div class="access">
<ul id="menu-home" class="access">
<li id="menu-item-10" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-10">About Us
<ul class="sub-menu">
<li id="menu-item-11" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-11">History
</li>
</ul>
</li>
</ul>
</div>
And here is the relevant CSS:
#access {
background: #222; /* Show a solid color for older browsers */
background: -moz-linear-gradient(#252525, #0a0a0a);
background: -o-linear-gradient(#252525, #0a0a0a);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#252525), to(#0a0a0a)); /* older webkit syntax */
background: -webkit-linear-gradient(#252525, #0a0a0a);
-webkit-box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
-moz-box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
box-shadow: rgba(0, 0, 0, 0.4) 0px 1px 2px;
clear: both;
display: block;
float: left;
margin: 0 auto 6px;
width: 100%;
}
#access ul {
font-size: 13px;
list-style: none;
margin: 0 0 0 -0.8125em;
padding-left: 0;
}
#access li {
float: left;
position: relative;
}
#access a {
color: #eee;
display: block;
line-height: 3.333em;
padding: 0 1.2125em;
text-decoration: none;
}
#access ul ul {
-moz-box-shadow: 0 3px 3px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 3px 3px rgba(0,0,0,0.2);
box-shadow: 0 3px 3px rgba(0,0,0,0.2);
display: none;
float: left;
margin: 0;
position: absolute;
top: 3.333em;
left: 0;
width: 188px;
z-index: 99999;
}
#access ul ul ul {
left: 100%;
top: 0;
}
#access ul ul a {
background: #f9f9f9;
border-bottom: 1px dotted #ddd;
color: #444;
font-size: 13px;
font-weight: normal;
height: auto;
line-height: 1.4em;
padding: 10px 10px;
width: 168px;
}
#access li:hover > a,
#access ul ul :hover > a,
#access a:focus {
background: #efefef;
}
#access li:hover > a,
#access a:focus {
background: #f9f9f9; /* Show a solid color for older browsers */
background: -moz-linear-gradient(#f9f9f9, #e5e5e5);
background: -o-linear-gradient(#f9f9f9, #e5e5e5);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f9f9f9), to(#e5e5e5)); /* Older webkit syntax */
background: -webkit-linear-gradient(#f9f9f9, #e5e5e5);
color: #373737;
}
#access ul li:hover > ul {
display: block;
}
#access .current-menu-item > a,
#access .current-menu-ancestor > a,
#access .current_page_item > a,
#access .current_page_ancestor > a {
font-weight: bold;
}
#img {border-bottom:2px solid #9bc5c4;margin:0;padding:0;max-height:125px;overflow:hidden;} #block-cck_blocks-field_hdr_img {height:128px;overflow:hidden;}
#nav {height:45px;background:url(img/main-nav-bkgd.jpg) repeat-x #26243c;width:1008px;height:45px;z-index:90;position:relative;}
#nav ul.nice-menu {width:993px;margin:0 0 0 15px;padding:0;display:inline;}
#nav ul.nice-menu li {display:block;float:left;background:none;border:none;position:relative;color:#FFF;font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;height:45px;font-size:13px;font-weight:bold;}
#nav ul.nice-menu li a {display:block;color:#FFF;font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;padding:13px 23px 14px 23px;font-size:13px;font-weight:bold;text-decoration:none;}
#nav ul.nice-menu li a:hover, #nav ul.nice-menu-down li.menuparent:hover a, #nav ul.nice-menu-down li.over a, #nav ul li.active-trail a {background:url(img/nav-over.jpg) repeat-x;}
#nav ul.nice-menu li ul {position:absolute;top:45px;left:0;}
#nav ul.nice-menu li ul li {width:200px;margin:0;padding:0;height:auto!important;}
#nav ul.nice-menu li ul li a, #nav ul.nice-menu-down li.menuparent ul li a {font-size:11px;color:#231f20;font-family:Georgia, "Times New Roman", Times, serif;display:block;clear:both;padding:5px 20px;margin:0;width:160px;background:#dfccb0!important;border-bottom:1px solid #FFF;font-weight:normal;}
#nav ul.nice-menu li ul li a:hover, #nav ul.nice-menu-down li.menuparent ul li a:hover {background:#d0b389!important;}
#nav ul.nice-menu li ul li ul {display:none;}
Any input on what I could be doing wrong???
Your navigation wrapper has a class of "active" but in your css you are targeting an ID.
Option 1
Change #access to .access
Option 2 (which might be easier)
Change <div class="access"> to <div id="access">
Working example
UPDATE: Okay I changed the margin on #access ul although now when I hover over it looks like this: http://imgur.com/NeUzN
Also is it possible to change the spacing between the page titles (sorry still learning css!)
I'm currently designing my wordpress theme and wondering how I could move the text up a bit to center up with the nav bar: http://i.imgur.com/BExiy.png
I'm using custom font as well. Here is my css:
#access {
background: #252525;
display: block;
float: left;
margin: 0 auto;
height: 40px;
}
#access ul {
list-style: none;
margin: -8px -13px -10px -13px;
padding-left: 0;
color:#000;
text-shadow:1px 1px 1px rgba(14,14,14,0.8);
text-transform:uppercase;
font: 24px Giantypo, Arial, Helvetica, sans-serif;
}
#access li {
float: left;
position: relative;
}
#access a {
display: block;
line-height: 2.5em;
padding: 0 1em;
text-decoration: none;
color:#f3f3f3;
}
#access ul ul {
box-shadow: 0 3px 3px rgba(0,0,0,0.2);
-moz-box-shadow: 0 3px 3px rgba(0,0,0,0.2);
-webkit-box-shadow: 0 3px 3px rgba(0,0,0,0.2);
display: none;
float: left;
position: absolute;
top: 2em;
left: 0;
z-index: 99999;
}
#access ul ul ul {
left: 100%;
top: 0;
}
#access ul ul a {
background: #3e5d8c;
line-height: 1em;
padding: .5em .5em .5em 1em;
width: 10em;
height: auto;
}
#access li:hover > a,
#access ul ul :hover > a {
background: #3e5d8c;
}
#access ul ul a:hover {
background: #3e5d8c;
}
#access ul li:hover > ul {
display: block;
}
}
Any help would be great!
Cheers,
Scott
Top margin of unordered list must be negatie value. For example:
margin: -7px 0 0 0;
Set the line-height to be equal to its height. On #access a, I believe, but I cannot know for sure without seeing the HTML. And I cannot know its height without seeing all of it live.