*I exhaustedly searched this site for an answer before posting a question, I attempted multiple solutions and nothing worked to my exact codes. While you may find duplicate questions on this site. I don't consider it to be a duplicate unless the coding is EXACTLY the same as well as the solutions. Nothing on this site worked for my exact coding therefore I needed to post my exact code for help. *
I have a menu that looks like the one below. and the drop down on it. Right now the nested ul just simply spreads throughout the page. it needs to show up in a nice drop down section under administration. I have tried searching for this and asking my colleagues none of them have done it before. I have created a jsFiddle here: http://jsfiddle.net/z3Lpm/
<div id="menu">
<ul>
<li>Home</li>
<li>Administration
<ul>
<li>Products</li>
</ul>
</li>
</ul>
</div>
(not my full menu but you get the point.)
and then my css:
#menu{
width: 100%;
border: 1px solid #000;
height: 50px;
background-color:#181818;
font-family: Helvetica, sans-serif;
font-size: 13px;
}
#menu ul{
margin-top: 20px;
}
#menu ul li{
list-style-type: none;
display: inline;
margin-left: 50px;
}
#menu ul li a:link{
color: #FFF;
text-decoration: none;
text-transform: uppercase;
padding-top: 40px;
padding-bottom: 40px;
padding-left: 20px;
padding-right: 20px;
}
#menu ul li a:visited{
color: #FFF;
text-decoration: none;
text-transform: uppercase;
}
#menu ul li a:hover{
color: #FFF;
background-color: #81B101;
-webkit-box-shadow: 0px 4px 5px rgba(50, 50, 50, 0.93);
-moz-box-shadow: 0px 4px 5px rgba(50, 50, 50, 0.93);
box-shadow: 0px 4px 5px rgba(50, 50, 50, 0.93);
}
Here, I didn't change up the colors or anything because I don't know what you are doing with them. Let me know if this works for you.
http://jsfiddle.net/talymo/LDNpG/
#menu{
background-color:#181818;
font-family: Helvetica, sans-serif;
font-size: 13px;
height:50px;
}
#menu ul{
list-style:none;
padding-top:15px;
}
#menu ul li{
padding:0px 20px;
width:auto;
float:left;
position:relative;
}
#menu ul li:hover > ul{
display:block;
}
#menu ul li a{
color: #FFF;
text-decoration: none;
text-transform: uppercase;
padding-top: 40px;
padding-bottom: 40px;
padding-left: 20px;
padding-right: 20px;
}
#menu ul li a:hover{
color: #FFF;
background-color: #81B101;
-webkit-box-shadow: 0px 4px 5px rgba(50, 50, 50, 0.93);
-moz-box-shadow: 0px 4px 5px rgba(50, 50, 50, 0.93);
box-shadow: 0px 4px 5px rgba(50, 50, 50, 0.93);
}
#menu ul li ul{
overflow:hidden;
padding:0;
margin:0;
display:none;
position:absolute;
top:20px;
}
Related
I want to create an underline when I hover over the links in my navigation bar. I'm not sure which id I should be targeting. Here's my JFiddle: https://jsfiddle.net/gzycz4h8/
Thanks in advance.
<ul id="nav">
<li>About</li>
<li>Writing</li>
<li>Multimedia</li>
<li>Resume</li>
<li>Contact</li>
</ul>
are you looking for something like this ?
#nav {
padding: 10px 0;
width:700px;
margin: 0 auto;
text-align: center;
list-style-type: none;
display:block;
text-decoration: none;
-webkit-box-shadow: 0 2px 10px -12px #999;
-moz-box-shadow: 0 8px 6px -6px #999;
box-shadow: 0 8px 6px -6px #999;
}
#nav li {
display: inline-block;
margin: 5px;
text-transform: uppercase;
}
#nav li a {
text-decoration:none;
}
#nav li a:hover {
text-decoration: underline;
text-decoration-color: black;
-o-transition:.4s;
-ms-transition:.4s;
-moz-transition:.4s;
-webkit-transition:.4s;
transition:.4s;
}
The most simple solution would be:
li a {
text-decoration:none;
}
li a:hover {
text-decoration: underline;
}
https://jsfiddle.net/LvLsckzw/
Or something like this: https://jsfiddle.net/m16gggk1/1/
#nav {
padding: 0;
width:700px;
margin: 0 auto;
text-align: center;
list-style-type: none;
display:block;
text-decoration: none;
-webkit-box-shadow: 0 2px 10px -12px #999;
-moz-box-shadow: 0 8px 6px -6px #999;
box-shadow: 0 8px 6px -6px #999;
}
#nav li {
display: inline-block;
margin: 0 5px;
text-transform: uppercase;
border-bottom:2px solid #fff;
}
#nav li a {
text-decoration:none;
}
#nav li a:hover {
color:red;
}
#nav li:hover {
border-bottom:2px solid red;
}
I have this HTML code
<div id="navbar">
<ul>
<li>Page1</li>
<li>page2</li>
<li id="NavItem">
page3
<div id="PopOver">
<div class="ow-button">
xnewPage1
xnewPage2
xnewPage3
</div>
</div>
</li>
<li>page4</li>
</ul>
</div>
CSS code
#navbar { position: relative; margin: 3px; }
#navbar ul {
padding: 0;
margin: auto;
background: #f0f0f0 url(../images/1px.png) repeat-x 0 -441px;
padding: 4px 0 4px 0;
}
#navbar li { display: inline; margin-right: 80px; }
#navbar li a {
font-family: EqualSansDemo;
font-size: 1.6em;
color: #555555;
text-shadow: 1px 1px 0px #fff; }
#navbar li a:hover { color: #0071e4; }
#PopOver {
position:absolute;
border:2px solid #07B1F1;
width:170px;
height:auto;
padding:15px 5px 10px 5px;
display:none;
top:30px;
left:229px;
background-color:#FFFFFF;
border-radius:8px;
-moz-border-radius:8px;
-webkit-border-radius:8px;
}
#NavItem:hover #PopOver {display:block}
.ow-button a {
display: block;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
width: 160px;
height: 28px;
font-family: Arial, "Nimbus Sans L", "FreeSans";
font-size: 14px;
font-weight: bold;
color: #FFFFFF;
text-align: center;
line-height: 28px;
text-shadow: 1px 1px 1px #6A6A6A;
text-decoration:none;
margin: 0px 5px 10px 5px;
background: #28A9FF;
}
.ow-button a:hover {
background: #48B6FF;
}
The problem:
"#navbar li a" will hide:
font-family: Arial, "Nimbus Sans L", "FreeSans";
font-size: 14px;
color: #FFFFFF;
text-shadow: 1px 1px 1px #6A6A6A;
Which "ow-button a" have..and will enable its own.
And I don't want that... How do I enable the full "ow-button a" CSS code?
The quick and dirty solution is to add !important to your ow-button a which will override #navbar li a.
The better solution is to use better scoped CSS. Use selectors like > to specify exactly the element you want to. In your case, it should look like this:
#navbar > ul > li > a
I made a jsFiddle for you: http://jsfiddle.net/6NrWF/.
I'm encountering two problems in Internet Explorer at the moment. The first is my navigation menu: the links are stacking on top of each other instead of going across the bar. Here is my code for the nav menu.
HTML
<div class="main-navigation" role="navigation" style="margin-top: 5px;">
<div class="nav-menu"><ul><li class="page_item page-item-8">design your own</li><li class="page_item page-item-10">fan photos</li><li class="page_item page-item-12">Win a free T-shirt</li></ul></div>
</div><!-- #site-navigation -->
CSS
.main-navigation li {
margin: 0px 20px 0px 0px;
position: relative;
text-align: center;
padding: 7px 0px;
}
.main-navigation li ul {
display: none;
margin: 0;
padding: 0;
position: absolute;
top: 100%;
z-index: 1;
}
.main-navigation li ul ul {
top: 0;
left: 100%;
}
.main-navigation ul li:hover > ul {
border-left: 0;
display: block;
}
.main-navigation li ul li a {
background: #efefef;
border-bottom: 1px solid #ededed;
display: block;
font-size: 11px;
font-size: 0.785714286rem;
line-height: 2.181818182;
padding: 8px 10px;
padding: 0.571428571rem 0.714285714rem;
width: 180px;
width: 12.85714286rem;
white-space: normal;
}
.main-navigation li ul li a:hover {
background: #e3e3e3;
color: #444;
}
.main-navigation .current-menu-item > a,
.main-navigation .current-menu-ancestor > a,
.main-navigation .current_page_item > a,
.main-navigation .current_page_ancestor > a {
color: #cb0000;
font-weight: bold;
}
The second problem is with my two ribbons I have for titles in the side bar.
The right bottom flap that gives it the wrap around look is not showing up.
HTML
<div class="ribbon"><strong>SPECIAL OFFERS</strong></div>
CSS
.ribbon {
padding-bottom: 7px;
padding-top: 8px;
padding-left: 3px;
color: #fff;
text-shadow: 1px 1px 0px #c1c1c1;
font-size: 15px;font-family:'Century Gothic',futura,'URW Gothic L',Verdana,sans-serif;
letter-spacing: 5px;
position:relative;
width:267px;
right:0px;
top:19px;
background-color:#212121;
-moz-border-radius:2px 0px 0px 2px; /*radius of 2px*/
-khtml-border-radius:2px 0px 0px 2px;
-webkit-border-radius:2px 0px 0px 2px;
-webkit-box-shadow: -2px 2px 4px rgba(50, 50, 50, 0.35);
-moz-box-shadow: -2px 2px 4px rgba(50, 50, 50, 0.35);
box-shadow: -2px 2px 4px rgba(50, 50, 50, 0.35);
}
.ribbon:after {
content:'';
width:0;
height:0;
border-color: #000 transparent transparent #000;
border-style:solid;
border-width:5px 5px;
position:absolute;
right:0;
bottom:-10px;
}
This code works in other major browsers, but not in IE.
For the first issue you should add anywhere you have display: inline-block for ie
zoom: 1;
*display: inline
Update
.main-navigation div.nav-menu > ul {
border-bottom: 1px solid #ededed;
border-top: 1px solid #ededed;
display: inline-block !important;
*display: inline
zoom: 1;
text-align: center;
width: 100%;
}
.main-navigation li a,
.main-navigation li {
display: inline-block;
*display: inline
zoom: 1;
text-decoration: none;
}
From the link you provided
the sub menu is not displaying properly help me please
i want it in CSS and HTML
submenu should be like a list it should be displayed
one down another but it is displaying one after another in same line
after hover on main menu the submenu should be displayed
<style>
#navbar {
position: absolute;
top: 0;
left: 0;
margin: 0;
padding:0;}
#navbar li
{
list-style: none;
float: left;
}
#navbar li a {
display: block;
padding: 3px 8px;
text-transform: uppercase;
text-decoration: none;
color: #999;
font-weight: bold; }
#navbar li a:hover {
color: #000; }
#navbar li ul {
display: none; }
#navbar li:hover ul, #navbar li.hover ul {
position: absolute;
display:list-item;
left: 0;
width: 100%;
margin: 0;
padding: 0; }
</style>
</head>
<body>
<ul id="navbar">
<li>Home</li>
<li>About Us
<ul>
<li>Subitem One</li>
<li>Second Subitem</li>
<li>thrid subitem</li>
</ul>
</li>
<li>Services</li>
<li>Products</li>
<li>Contact</li>
</ul>
add this in your css
#navbar li
{
list-style: none;
float: left;
position:relative;
}
here is jsFiddle file
Live demo
HI now used to this css and created drop down navi in pure css
Css
#navbar{
background:#0082c8;
position:relative;
margin-top:15px;
}
#navbar > li{
float:left;
margin:0 10px;
position:relative;
padding:14px 0;
}
#navbar li a, .subnavi li a{
color:white;
text-decoration:none;
display:inline-block;
line-height:29px;
padding:0 13px;
font-size:16px;
font-family:arial;
text-shadow: 0px 2px 2px #034e9f;
filter: dropshadow(color=#034e9f, offx=0, offy=2);
}
#navbar > li:hover > a, li:hover > a , #navbar li a.active{
background:#055c9f;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: inset 0px 3px 3px 0px #042960;
-moz-box-shadow: inset 0px 3px 3px 0px #042960;
box-shadow: inset 0px 3px 3px 0px #042960;
border:1px solid #009ada;
color:#f7cf00;
line-height:27px;
padding:0 12px;
}
.subnavi{
position:absolute;
display:none;
top:51px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0px 0px 3px 1px #979395;
-moz-box-shadow: 0px 0px 3px 1px #979395;
box-shadow: 0px 0px 3px 1px #979395;
background:#0082c8;
border:1px solid #005890;
padding:10px 0;
white-space:nowrap;
}
#navbar li:hover .subnavi{
display:block;
}
#navbar .subnavi li{
margin:0;
}
#navbar .subnavi li a{
display:block;
font-size:13px;
padding:0 15px;
border-radius:0;
line-height:27px;
}
#navbar .subnavi li a:hover{
padding:0 15px;
border-radius:0;
border-left:0;
border-right:0;
line-height:25px;
}
#navbar:after{
content:'';
clear:both;
display:block;
overflow:hidden;
}
HTML
<ul id="navbar">
<li>About</li>
<li>Demo
<ul class="subnavi">
<li>Demo</li>
<li>Demo</li>
<li>Demo</li>
<li>Demo</li>
<li>Demo</li>
</ul>
</li>
<li>Demo</li>
</ul>
Live demo
Add this style for your submenus:
#navbar li ul li
{
float: none;
}
Please hover your mouse over the MORE button in the menu here: http://jsfiddle.net/XHard/1/ You will see that there is a list containing the words New clean list. I want to style that list but because it is inside the menu, it already has a styling to it.
I want to create a new clean style for it but cannot find a way to do it. I tried playing around with #mega moreleftbar a but the original menu list styling is still there.
Is there a way to make a new clean styling for a list inside that menu?
Here is part of my HTML:
<div id="second-menu" class="clearfix">
<ul id="secondary-menu" class="nav sf-js-enabled">
<li class="manimation">Animation</li>
</ul>
<ul id="mega">
<li class="dif mmore" style="background:none;">More...
<div>
<moretopbar>
<ul>
<li class="mgames">Games</li>
<li class="mliterature">Literature</li>
<li class="marts">Arts</li>
<li class="mcontact" style="background:none;">Contact</li>
</ul>
</moretopbar>
<morecontainer>
<moreleftbar>
<ul>
<li>New clean list 1</li>
<li>New clean list 2</li>
<li>New clean list 3</li>
<li>New clean list 4</li>
</ul>
</moreleftbar>
</morecontainer>
</div>
</li>
</ul>
</div> <!-- end #second-menu -->
Here is part of my CSS:
ul#top-menu li { padding-right: 2px; background: url(images/menu-bg.png) repeat-y top right; }
ul#top-menu a { font-size: 11px; color: #ffffff; text-decoration: none; text-transform: uppercase; font-weight: bold; text-shadow: 1px 1px 1px rgba(0,0,0,0.7); padding: 16px 12px 10px; }
ul#top-menu a:hover { color: #ebbe5e;}
ul#top-menu > li.current_page_item > a { color: #ebbe5e !important; }
ul#top-menu li ul, #mobile_menu { width: 170px !important; padding: 0; background: #161616 url(images/header-bg.png); top: 45px !important; -moz-box-shadow:3px 3px 7px 1px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 3px 3px 7px 1px rgba(0, 0, 0, 0.1); box-shadow: 3px 3px 7px 1px rgba(0, 0, 0, 0.1); -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; border-top-left-radius: 0px;-moz-border-radius-topleft: 0px; border-top-right-radius: 0px; -webkit-border-top-left-radius: 0px; -moz-border-radius-topright: 0px; -webkit-border-top-right-radius: 0px; z-index: 9999px; display: none; }
ul#top-menu ul li, #mobile_menu li a { margin: 0 !important; padding: 10px 7px 10px 25px !important; background: url(images/top-menu-separator.png) repeat-x; }
ul#top-menu ul li.first-item { background: none; }
ul#top-menu ul li a, #mobile_menu a { padding: 0 !important; width: 138px; }
ul#top-menu li:hover ul ul, ul#top-menu li.sfHover ul ul { top: -1px !important; left: 171px !important; -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }
ul#top-menu li.menu-gradient { background: url("images/top-shadow.png") repeat-x; position: absolute; top: 0; left: 0; width: 202px; height: 7px !important; }
ul#secondary-menu li { background: url(images/secondary-menu-bg.png) repeat-y top right; }
ul#secondary-menu a { font-size: 16px; color: #48423f; text-decoration: none; text-transform: uppercase; font-weight: bold; padding: 22px 16px; }
ul#secondary-menu a:hover { color: #ffffff; text-shadow: 1px 1px 0 #404747; }
#second-menu ul.nav li:hover a {color: #ffffff; text-shadow: 1px 1px 0 #404747; }
ul#secondary-menu > li.current_page_item > a { color: #919e9e !important; }
ul#secondary-menu li ul, #category_mobile_menu { width: 360px !important; padding: 7px 0 10px; background: #fff url(images/content-bg.png); top: 55px !important; -moz-box-shadow:3px 3px 7px 1px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 3px 3px 7px 1px rgba(0, 0, 0, 0.1); box-shadow: 3px 3px 7px 1px rgba(0, 0, 0, 0.1); -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; border-top-left-radius: 0px;-moz-border-radius-topleft: 0px; border-top-right-radius: 0px; -webkit-border-top-left-radius: 0px; -moz-border-radius-topright: 0px; -webkit-border-top-right-radius: 0px; z-index: 9999px; display: none; }
ul#secondary-menu ul li, #category_mobile_menu li a { margin: 0 !important; padding: 8px 0 8px 30px !important; width: 150px; float: left; }
ul#secondary-menu ul li a, #category_mobile_menu a { padding: 0 !important; }
ul#secondary-menu li:hover ul ul, ul#secondary-menu li.sfHover ul ul { top: -8px !important; left: 180px !important; -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }
ul#secondary-menu ul li.even-item { background: none; }
.manimation:hover{
background:#43cf61 !important;
}
.mmore:hover{
background:#4b5571 !important;
}
.mliterature:hover{
background:#2c8f83 !important;
}
.mgames:hover{
background:#e34328 !important;
}
.marts:hover{
background:#cc226a !important;
}
.mcontact:hover{
background:#9395aa !important;
}
/* ---------- Mega Drop Down --------- */
ul#mega li { padding-right: 0px; background: url(images/secondary-menu-bg.png) repeat-y top right; }
#mega {
list-style:none;
font-weight:bold;
height:2em;
}
#mega li {
padding: 23px 0px;
background:#999;
border:0px solid #000;
float:left;
text-align:center;
position:relative;
}
#mega li:hover {
background:#eee;
border-bottom:0; /* border-bottom:0; and padding-bottom:1px; keeps <li> and <div> connected */
z-index:1; /* shadow above adjacent li */
}
#mega a { font-size: 16px; color: #48423f; text-decoration: none; text-transform: uppercase; font-weight: bold; padding: 22px 16px;}
ul#mega a:hover { color: #FFFFFF; text-shadow: 1px 1px 0 #404747; }
/* ----------- Hide/Show Div ---------- */
#mega div {
-moz-border-bottom-colors: none;
-moz-border-image: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background: none repeat scroll 0 0 #FFFFFF;
border-color: -moz-use-text-color #48423F #48423F;
border-right: 1px solid #48423F;
border-style: none solid solid;
border-width: 0 1px 1px;
font-weight: normal;
left: -999em;
margin-top: 1px;
position: absolute;
text-align: left;
width: 496px;
}
/* --------- Within Div Styles --------- */
#mega li:hover div {
left: -1px;
top: auto;
}
#mega li.dif:hover div {
left: -407px;
top: 72px;
}
#mega li.mmore:hover > a {
color: #FFFFFF; text-shadow: 1px 1px 0 #404747; /* Ensures hover on MORE remains */
}
#mega div h2 {
background: none repeat scroll 0 0 #999999;
clear: both;
float: left;
font-size: 1em;
margin: 10px 0 5px;
padding: 0 10px;
position: relative;
width: 300px;
}
#mega div moretopbar {
clear: both;
float: left;
position: relative;
margin-left:1px;
margin-right:1px;
width: 495px;
height: 74px;
background-image: url(images/morebgwide.png);
background-size:495px 74px;
background-repeat:no-repeat;
}
#mega div p {
float: left;
padding-left: 10px;
position: relative;
width: 106px;
}
#mega div p a {
clear: left;
float: left;
line-height: 1.4;
text-decoration: underline;
width: 100%;
}
#mega div a:hover, #mega div a:focus, #mega div a:active {
text-decoration: none;
}
#mega div morecontainer {
width: 495px;
}
#mega div moreleftbar {
width: 70%;
}
#mega moreleftbar a { /* I want to style the list here - clean slate*/
margin-left: 0;
padding-left: 0;
list-style-type: none;
font-family: Arial, Helvetica, sans-serif;
color: #cc6600;
}
Although, I would advice overlooking the fiddle for a visual presentation of the issue: http://jsfiddle.net/XHard/1/
There must be a way to make a new clean list in that drop down menu. Can you figure out how? If you will answer, please be detailed as my coding knowledge is limited - ideally with an updated fiddle.
Ok so just had a look at firebugs output on the styling of the <ul> tag you have. And the CSS rules are specific to the <ul> tags within #mega.
So I added this CSS that targets the UL you want to style and reset a few rules:
ul#mega moreleftbar ul,
ul#mega moreleftbar ul li,
ul#mega moreleftbar ul li a,
ul#mega moreleftbar ul li a:hover
{
padding:0;
border:0;
margin:0;
color:#000000;
font-size:inherit;
font-weight:normal;
background:none;
}
JSfiddle example
Notice your original rule for styling the <li>
ul#mega li
This will be overwritten by the targetted rules I've applied above.
By being more specific with the rules, they overwrite less specific styles (unless a style has an !important tagged to it).
.manimation:hover{
background:#43cf61 !important;
}
The above rule for example will stop you being able to apply any further background-color changes to any elements that are covered by the rule. !important is not a good thing to use unless it is absolutely necessary.