I am trying to place a black border below the dropdown menu, then having the "selected" page which is currently the "Home" page being underlined using a orange border. I am trying to overlap the orange border on the black border.
http://jsfiddle.net/46z5su4u/
Edited
Some people seems to be confused, I want to put the orange line on top of the black line.
http://jsfiddle.net/46z5su4u/2/
Any advices?
HTML:
<h1>Drop Down Menu</h1>
<header>
<nav id="primary_nav_wrap">
<ul>
<li class="current-menu-item">Home</li>
<li>Menu 1
<ul>
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
<li>Sub Menu 4
</li>
<li>Sub Menu 5</li>
</ul>
</li>
<li>Menu 2
<ul>
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
</ul>
</li>
<li>Menu 3
<ul>
<li class="dir">Sub Menu 1</li>
<li class="dir">Sub Menu 2 THIS IS SO LONG IT MIGHT CAUSE AN ISSEUE BUT MAYBE NOT?
</li>
<li>Sub Menu 3</li>
<li>Sub Menu 4</li>
<li>Sub Menu 5</li>
</ul>
</li>
<li>Menu 4</li>
<li>Menu 5</li>
<li>Menu 6</li>
<li>Contact Us</li>
</ul>
</nav>
</header>
CSS:
header
{
border-bottom:4px solid #3a3a3a;
}
#primary_nav_wrap
{
margin-top:15px;
margin-bottom:-4px;
position:relative;
}
#primary_nav_wrap ul
{
list-style:none;
float:left;
margin:0;
padding:0;
}
#primary_nav_wrap ul a
{
display:block;
text-decoration:none;
line-height:32px;
padding:0 15px;
font-family:"Open Sans","Lucida Grande",Tahoma,"Trebuchet MS",Verdana,Arial,sans-serif;
font-size:1.1em;
}
#primary_nav_wrap ul li
{
position:relative;
float:left;
margin:0;
padding:0;
}
#primary_nav_wrap ul li.current-menu-item
{
border-bottom:4px solid #ff7500;
font-weight:700;
}
#primary_nav_wrap ul li.current-menu-item a
{
color:#333;
}
#primary_nav_wrap ul li a:hover
{
color: #ff7500;
}
#primary_nav_wrap ul ul
{
display:none;
position:absolute;
top:100%;
left:0;
background:#f8f8f8;
padding: 0 12px;
box-shadow: 0 2px 2px #ccc;
}
#primary_nav_wrap ul ul li
{
float:none;
width:150px;
border-bottom: solid 1px #f2f2f2;
border-top: solid 1px #fff;
}
#primary_nav_wrap ul ul li:after
{
content: "";
}
nav ul ul li:last-child a
{
border-bottom: none;
}
nav ul ul li:first-child a
{
border-top: none;
}
#primary_nav_wrap ul ul a
{
line-height:120%;
padding:10px 6px;
}
#primary_nav_wrap ul li:hover > ul
{
display:block;
}
you may need a lower boarder when you move?
#primary_nav_wrap ul li a:hover
{
color: #ff7500;
border-top: 4px solid #ff7500;/*add*/
}
Try this http://jsfiddle.net/46z5su4u/1/
this is all i have added
#primary_nav_wrap ul li ul li {
border-bottom:1px solid orange;
}
Fixed
http://codepen.io/anon/pen/bfgvo
Added to html
<div class="clearBoth"></div>
<div id="top_blackline"></div>
Added to css
.clearBoth
{
clear:both;
}
#top_blackline
{
margin-top:-4px;
width: 100%;
border-bottom:4px solid #3a3a3a;
}
Just set the dark border on the first-level <li>s instead of <header>.
So the updated css code will look like this:
header {
position: absolute; /* removed border */
}
/* add the following rule */
#primary_nav_wrap > ul > li {
border-bottom:4px solid #3a3a3a;
}
which sets the dark border on first-level <li>s only using the direct child selector >, more on this selector here.
a preview of the code above is here.
Related
What do I need to include in my CSS to get my menu text to stay black when hovering over a submenu?
I've tried systematically going through my current :hover elements, including > when ever possible, and adapting the relevant parts from other codes into the CSS. I've also combed through similar questions in hopes to find applicable code but have not been successful.
#menu {
width: 100%;
position: fixed;
background: #333;
color: #fff;
}
#menu ul.left {
position:relative;
float:left;
margin:0;
padding:0px;
}
#menu ul a {
display:block;
color:#fff;
text-decoration:none;
padding:0 15px;
}
#menu ul a:hover {
display:block;
color: #333;
text-decoration:none;
padding:0 15px;
}
#menu ul li {
list-style-type: none;
position:relative;
float:left;
margin:0;
padding:0px;
}
#menu ul li:hover {
background:#f6f6f6;
color:#333;
}
#menu ul ul {
display:none;
position:absolute;
background: #f6f6f6;
color: #333;
}
#menu ul li:hover > ul {
display:block;
}
<nav id="menu">
<ul class="left">
<li>Home</li>
<li>Menu 1
<ul>
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
<li>Sub Menu 4
</ul>
</li>
</ul>
</nav>
Expected results: hovering from Menu 1 to Sub Menu x will keep the #333 colored text on Menu 1.
Actual results: hovering from Menu 1 to Sub Menu x will revert to #f6f6f6 colored text on Menu 1.
Added a element to the #menu ul li:hover in css.
#menu {
width: 100%;
position: fixed;
background: #333;
color: #fff;
}
#menu ul.left {
position:relative;
float:left;
margin:0;
padding:0px;
}
#menu ul a {
display:block;
color:#fff;
text-decoration:none;
padding:0 15px;
}
#menu ul a:hover {
display:block;
color: #333;
text-decoration:none;
padding:0 15px;
}
#menu ul li {
list-style-type: none;
position:relative;
float:left;
margin:0;
padding:0px;
}
#menu ul li:hover a{
background:#f6f6f6;
color:#333;
}
#menu ul ul {
display:none;
position:absolute;
background: #f6f6f6;
color: #333;
}
#menu ul li:hover > ul {
display:block;
}
<nav id="menu">
<ul class="left">
<li>Home</li>
<li>Menu 1
<ul>
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
<li>Sub Menu 4
</ul>
</li>
</ul>
</nav>
I'm trying to create a navigation menu similar to the picture attached but I'm having trouble with the CSS. I have a basic nested unordered list but I can't figure out how to styles it to look as close as possible to the specifications. Any help/links would be appreciated.
nav {
border-bottom:1px solid #ccc;
}
nav ul {
list-style:none;
padding:0.35em;
margin:0 0.5em;
}
nav li {
border-right:1px solid black;
display:inline-block;
padding:0.15em 0.25em;
position:relative;
}
nav li:first-child {
border-left:1px solid black;
}
nav ul ul {
background:white;
border:1px solid #ccc;
box-shadow:2px 2px 4px rgba(0,0,0,0.5);
display:none;
left:-0.25em;
min-width:200px;
padding:0.5em;
position:absolute;
top:1.5em;
}
nav li:hover {
font-weight:bold;
}
nav li:hover ul {
font-weight:normal;
}
nav li:hover ul {
display:block;
}
nav li li {
border:none !important;
display:block;
margin:0;
padding:0;
white-space:nowrap;
}
<nav>
<ul>
<li>Item 1
<ul>
<li>Subitem 1</li>
<li>Subitem 2</li>
<li>Subitem 3</li>
</ul>
</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
</ul>
</nav>
I have a template with a simple menu inside the site, and I am a newbie with css.
I Want to add a sub menu just below the menu and a subsub menu on the right side
of the sub menu.
Here is my html code:
<div class="site-nav">
<ul>
<li><span>Home</span></li>
<li><span>A UNNO</span></li>
<li><span>Produtos</span>
<ul>
<li>Product 1
<ul>
<li>Sub Product 1</li>
<li>Sub Product 2</li>
<li>Sub Product 3</li>
</ul>
</li>
<li><span>Serviços</span></li>
</ul>
</ul>
</div>
and this is the CSS that belongs to the menu.
.site-nav {
width:100%;
overflow:hidden;
}
.site-nav ul {
float: right;
background-color: #1e1a18;
height: 70px;
border-top: 1px solid #221d19;
}
.site-nav ul li {
font-size:1.08em;
float:left;
background:url(images/divider.gif) repeat-y right top;
padding-right:2px;
}
.site-nav ul li a {
color:#fff;
text-decoration:none;
display:block;
background:url(images/nav-bg.gif) no-repeat 21px 32px;
width:119px;
height:70px;
}
.site-nav ul li a span {
display:block;
padding:26px 0 0 35px;
}
.site-nav ul li a:hover,
.site-nav ul li a.active {
background-color:#ed1c24;
}
.site-nav ul li.twitter {
background:none;
padding:23px 0 0 0;
border-right:1px solid #080808;
text-align:center;
width:102px;
}
.site-nav ul li.twitter a,
.site-nav ul li.twitter a:hover {
background:none;
}
.site-nav ul li.twitter a {
display:inline;
}
Try this:
<nav>
<ul>
<li class="tabs">Home</li>
<li class="tabs">A UNNO</li>
<li class="tabs">Produtos
<ul>
<li>Sub Product 1
<ul>
<li>Sub Sub Product 1</li>
</ul>
</li>
<li>Sub Product 2</li>
<li>Sub Product 3</li>
</ul>
</li>
<li class="tabs">Servicos</li>
</ul>
</nav>
and use a display: none; to hide the submenus and only show them on hover.
JSFIDDLE
How do I make a div menu button drop down and add sub menus to it using only HTML & CSS.
HTML:
<div class="right_menu">Change Password
Sign Out
</div>
CSS:
.sign_out_button{
background-color: #2fa4e7;
padding-top: 16px;
padding-bottom: 16px;
padding-left:10px;
padding-right:10px;
color: #FFF;
float: left;
text-decoration: none;
}
.sign_out_button:hover{background-color:#1892d7;}
.sign_out_button a{color:#FFF;
text-decoration: none;}
Here is another choise without javascript and it works fine too
<ul>
<li>
Menu
<ul>
<li>Submenu</li>
<li>Submenu</li>
<li>Submenu</li>
</ul>
</li>
</ul>
This is your html, insert to your page. Now comes the CSS
ul {
width:200px;
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
ul li {width:200px;
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #fff;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
ul li:hover {
background: #555;
color: #fff;
}
ul li ul {
padding: 0;
position: absolute;
top: 48px;
left: 0;
width:200px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
ul li ul li {
background: #555;
display: block;
color: #fff;
text-shadow: 0 -1px 0 #000;
}
ul li ul li:hover { background: #666; }
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
And here you got a demo of that
https://jsfiddle.net/r50kbnq7/
I linked a jsfiddle below, have a look.
CSS:
#primary_nav_wrap
{
margin-top:15px
}
#primary_nav_wrap ul
{
list-style:none;
position:relative;
float:left;
margin:0;
padding:0
}
#primary_nav_wrap ul a
{
display:block;
color:#333;
text-decoration:none;
font-weight:700;
font-size:12px;
line-height:32px;
padding:0 15px;
font-family:"HelveticaNeue","Helvetica Neue",Helvetica,Arial,sans-serif
}
#primary_nav_wrap ul li
{
position:relative;
float:left;
margin:0;
padding:0
}
#primary_nav_wrap ul li.current-menu-item
{
background:#ddd
}
#primary_nav_wrap ul li:hover
{
background:#f6f6f6
}
#primary_nav_wrap ul ul
{
display:none;
position:absolute;
top:100%;
left:0;
background:#fff;
padding:0
}
#primary_nav_wrap ul ul li
{
float:none;
width:200px
}
#primary_nav_wrap ul ul a
{
line-height:120%;
padding:10px 15px
}
#primary_nav_wrap ul ul ul
{
top:0;
left:100%
}
#primary_nav_wrap ul li:hover > ul
{
display:block
}
HTML:
<h1>Simple Pure CSS Drop Down Menu</h1>
<nav id="primary_nav_wrap">
<ul>
<li class="current-menu-item">Home</li>
<li>Menu 1
<ul>
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
<li>Sub Menu 4
<ul>
<li>Deep Menu 1
<ul>
<li>Sub Deep 1</li>
<li>Sub Deep 2</li>
<li>Sub Deep 3</li>
<li>Sub Deep 4</li>
</ul>
</li>
<li>Deep Menu 2</li>
</ul>
</li>
<li>Sub Menu 5</li>
</ul>
</li>
<li>Menu 2
<ul>
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
</ul>
</li>
<li>Menu 3
<ul>
<li class="dir">Sub Menu 1</li>
<li class="dir">Sub Menu 2 THIS IS SO LONG IT MIGHT CAUSE AN ISSEUE BUT MAYBE NOT?
<ul>
<li>Category 1</li>
<li>Category 2</li>
<li>Category 3</li>
<li>Category 4</li>
<li>Category 5</li>
</ul>
</li>
<li>Sub Menu 3</li>
<li>Sub Menu 4</li>
<li>Sub Menu 5</li>
</ul>
</li>
<li>Menu 4</li>
<li>Menu 5</li>
<li>Menu 6</li>
</ul>
</nav>
http://jsfiddle.net/p9mrdk1d/
This is Very simple. here it is a simple code.........
===============HTML=================
<ul id="menu">
<li><span>HerĹa 1</span></li>
<li><span>HerĹa 2</span></li>
<li><span>HerĹa 3</span>
<ul>
<li><span>Level 2-A-1</span>
<ul>
<li><span>Level 3-A-1</span>
<ul>
<li><span>Level 4-A-1</span>
<ul>
<li><span>Level 5-A-1</span></li>
</ul>
</li>
<li><span>Level 4-A-2</span></li>
</ul>
</li>
<li><span>Level 3-A-2</span></li>
<li><span>Level 3-A-3</span></li>
</ul>
</li>
<li><span>Level 2-A-2</span></li>
<li><span>Level 2-A-3</span></li>
<li><span>Level 2-A-4</span></li>
</ul>
</li>
</ul>
=============CSS================
* {
list-style:none;
margin:0;
padding:0;
font-size:1em;
cursor:pointer;
}
#menu{
margin:3px;
}
#menu > li{ /* Top Level */
float:left;
margin-right:3px;
}
#menu > li > span{
display:block;
background:#0ac;
padding:3px 10px;
}
#menu > li:hover > span{
color:#fff;
}
#menu > li > ul{ /* Second Level */
display:none;
background:#08a;
}
#menu > li:hover > ul{
display:block;
position:absolute;
}
#menu > li > ul > li > span{
display:block;
padding:3px 10px;
border-top:solid 3px #fff;
}
#menu > li > ul > li:hover > span{
color:#fff;
}
#menu > li > ul li > ul{ /* Third Level & beyond */
display:none;
background:#068;
}
#menu > li > ul li:hover > ul{
display:block;
position:absolute;
left:100%;
border-left:solid 3px #fff;
top:0;
width:auto;
}
#menu > li > ul > li ul > li{
display:block;
padding:3px 10px;
border-top:solid 3px #fff;
white-space:nowrap;
}
#menu > li > ul > li ul > li:hover > span{
color:#fff;
}
I created a fiddle with my own div menu with dropdown. You can add icons to it and change as you need it. You need to use jquery. I will add later another without jquery.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<div class="LEFT-MENU">
<ul>
<li>
MENU 1
<ul class="LEFT-SUBMENU">
<li>SUBMENU 1</li>
<li>SUBMENU 2</li>
<li>SUBMENU 3</li>
<li>SUBMENU 4</li>
</ul></li>
</ul></div>
https://jsfiddle.net/1tueu0tq/
Click there and watch the demo. If you like it just copy and paste to your site
i have a menu that when i hover has a drop down i follow this
and this but unfortunately im getting different result than expected..im getting list but it is displayed as line horizontally and not vertically like the example here is the code i added to make the drop down
css
ul # menu li ul .submenu{
display:none;
}
ul # menu li : hover ul .submenu{
display:block;
}
here is the html
<div id="menu">
<ul id="menu-list">
<li id="">Home</li>
<li id="">
Menu
<ul class="sub-menu">
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
<li>Sub Menu 4</li>
</ul>
</li>
<li id="">Menu</li>
<li id="">Menu</li>
<li id="">Menu</li>
</ul>
</div>
Here you go:
Updated Fiddle
Just the small change. Made UL id = "menu"
<ul id="menu">
<li id="home">Home</li>
<li id="townoffice">
Menu
<ul class="sub-menu">
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
<li>Sub Menu 4</li>
</ul>
</li>
<li id="busines">Menu</li>
<li id="residents">Menu</li>
<li id="tourists">Menu</li>
</ul>
HTML
<ul id="nav" class="sixteen columns">
<li>Home
</li>
<li>Portfolio
<ul>
<li>Asia
<ul>
<li>Korea</li>
<li>China</li>
<li>Japan</li>
</ul>
</li>
<li>Europe
<ul>
<li>France</li>
<li>Germany</li>
<li>Italy</li>
</ul>
</li>
</ul>
</li>
</ul>
CSS
#nav {
width:800px;
margin:30px 50px;
padding: 0;
float:left;
}
#nav li {
list-style: none;
float: left;
padding:0 10px;
background-color:#367FB3;
color:white;
}
#nav li a:hover {
background-color:#52baff;
color:#fff;
}
//daf adf
/*--temp--*/
#nav ul ul li {
clear:left;
}
#nav ul ul {
position:absolute;
left:14em;
top:0;
}
#nav ul ul li a {
display:block;
padding: 3px 15px;
color: #242424;
text-decoration: none;
font-size:13px;
font-family:"Lato" !important;
}
/*--end temp--*/
#nav li a {
display: block;
padding: 3px 15px;
color: #242424;
text-decoration: none;
font-size:13px;
font-family:"Lato" !important;
}
#nav a:hover {
color:#367FB3;
}
#nav a:active {
color:#367FB3;
}
#nav li ul {
display: none;
width: 14em;
/* Width to help Opera out */
background-color:transparent;
z-index:666;
}
#nav li:hover ul, #nav li.hover ul {
display: block;
position: absolute;
margin:0px -10px;
padding:0px;
}
#nav li:hover ul ul {
display:none;
}
#nav li ul li:hover ul {
display:block
}
#nav li:hover li, #nav li.hover li {
float: none;
line-height:30px;
}
#nav li:hover li a, #nav li.hover li a {
background-color:#367FB3;
color:#fff;
font-size:13px;
font-family:"Lato" !important;
}
#nav li li a:hover {
background-color:#52baff;
color:#fff;
}
FIDDLE