HTML Code:
<div id="nav">
<div id="nav_wrapper">
<ul>
<li>
Admin <img src="" />
<ul>
<li>Adicionar Eventos</li>
<li>Actualizar Eventos</li>
<li>Eliminar Eventos</li>
</ul>
</li>
</ul>
</div>
</div>
CSS:
body{
padding:0;
margin:0;
overflow-y:scroll;
font-family:Arial;
font-size:18px;
}
#nav{
background-color:#333;
}
#nav_wrapper{
width:960px;
margin:0 auto;
text-align:left;
}
#nav ul{
list-style-type:none;
padding:0;
margin:0;
position:relative;
}
#nav ul li{
display:inline-block;
}
#nav ul li:hover{
background-color:#333;
}
#nav ul li img{
vertical-align:middle;
padding-left:5px;
}
#nav ul li a,visited{
color:#ccc;
display:block;
padding:15px;
text-decoration:none;
}
#nav ul li a:hover{
color:#ccc;
text-decoration:none;
}
#nav ul li:hover ul{
display:block;
}
#nav ul ul{
display:none;
position:absolute;
background-color:#333;
border: 5px solid #222;
border-top:0;
margin-left:-5px;
min-width:200px;
}
#nav ul ul li{
display:block;
}
#nav ul ul li a,visited{
color:#ccc;
}
#nav ul ul li a:hover{
color:#099;
}
I receive this: http://imgur.com/eMzuvfg
I want to put only Admin block visible and not the full header. Only one block black visible and in left side.
Someone can help me?
I think you want like this..
just replace the class from
#nav{
background-color:#333;
}
to
#nav{
width:100px;
background-color:#333;
}
Your question is confusing.. anyhow you need like this?
if no, please make your question little more detailed.
html
<div id="nav">
<div id="nav_wrapper">
<ul>
<li>
Admin <img src="" />
<ul>
<li>Adicionar Eventos</li>
<li>Actualizar Eventos</li>
<li>Eliminar Eventos</li>
</ul>
</li>
</ul>
</div>
</div>
css
body{
padding:0;
margin:0;
overflow-y:scroll;
font-family:Arial;
font-size:18px;
}
#nav{
background-color:#333;
}
#nav_wrapper{
float:left;
margin:0 auto;
text-align:left;
background-color:#333;
}
#nav ul{
list-style-type:none;
padding:0;
margin:0;
position:relative;
}
#nav ul li{
display:inline-block;
}
#nav ul li:hover{
background-color:#333;
}
#nav ul li img{
vertical-align:middle;
padding-left:5px;
}
#nav ul li a,visited{
color:#ccc;
display:block;
padding:15px;
text-decoration:none;
}
#nav ul li a:hover{
color:#ccc;
text-decoration:none;
}
#nav ul li:hover ul{
display:block;
}
#nav ul ul{
display:none;
position:absolute;
background-color:#333;
border: 5px solid #222;
border-top:0;
margin-left:-5px;
min-width:200px;
}
#nav ul ul li{
display:block;
}
#nav ul ul li a,visited{
color:#ccc;
}
#nav ul ul li a:hover{
color:#099;
}
Related
I'm currently working on my website and I have an existing navigation bar. The problem is that I have too much information to share on one page. That's why I'd like to implement a dropdown menu in the existing navigation bar. I've tried many many things but it all seems to screw up my lay-out of the css or it completely deletes the navigation bar.
I got an exisiting code for a dropdown menu but I simply am not able to blend it with the existing css code. I got this code from the internet, it is not my property.
My HTML:
<div id="menu">
<ul>
<li class="current_page_item">Home</li>
<li>Onze service</li>
<li>Ons team</li>
<li>Prijzen</li>
<li>Contact</li>
</ul>
</div>
My CSS:
#menu
{
position: absolute;
right: 0;
top: 1em;
}
#menu ul
{
display: inline-block;
}
#menu li
{
display: block;
float: left;
text-align: center;
line-height: 60px;
}
#menu li a, #menu li span
{
display: inline-block;
margin-left: 1px;
padding: 0em 1.5em;
letter-spacing: 0.10em;
text-decoration: none;
font-size: 1.0em;
text-transform: uppercase;
outline: 0;
color: #212121;
background: #ECECEC;
}
#menu li:hover a, #menu li.active a, #menu li.active span
{
}
#menu .current_page_item a
{
background: #E24E2A;
color: #FFF;
}
#menu .icon
{
}
Drop down menu:
#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
}
Thanks in advance!
Your navigation wrapper is menu whereas in the CSS from online it is primary_nav_wrap, so swap instances of these to menu.
In the html itself nested unordered list elements is used for the drop-downs, so add these under the list element where you need a drop-down.
Html:
<div id="menu">
<ul>
<li class="current_page_item">Home<ul>
<li>sub1</li>
<li>sub2</li>
<li>sub3</li>
</ul>
<li>Onze service</li>
<li>Ons team</li>
<li>Prijzen</li>
<li>Contact</li>
</ul>
</div>
CSS:
#menu ul {
display:inline-block;
list-style:none;
position:relative;
float:left;
margin:0;
padding:0
}
#menu li {
display:block;
float:left;
text-align:center;
line-height:60px
}
#menu li a,#menu li span {
display:inline-block;
margin-left:1px;
padding:0 1.5em;
letter-spacing:.1em;
text-decoration:none;
font-size:1em;
text-transform:uppercase;
outline:0;
color:#212121;
background:#ECECEC
}
#menu .current_page_item a {
background:#E24E2A;
color:#FFF
}
#menu {
margin-top:15px
}
#menu 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
}
#menu ul li {
position:relative;
float:left;
margin:0;
padding:0
}
#menu ul li.current-menu-item {
background:#ddd
}
#menu ul li:hover {
background:#f6f6f6
}
#menu ul ul {
display:none;
position:absolute;
top:100%;
left:0;
background:#fff;
padding:0
}
#menu ul ul li {
float:none;
width:200px
}
#menu ul ul a {
line-height:120%;
padding:10px 15px
}
#menu ul ul ul {
top:0;
left:100%
}
#menu ul li:hover > ul {
display:block
}
Here is a jsfiddle of the code merged:
https://jsfiddle.net/o51pp5s6/
We are working on tabbed menu. Submenus are not working in chrome but are working in firefox.
body {
background:#FFF;
margin:0;
padding:0;
}
.example {
width:1000px;
height:570px;
border-radius:3px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
font-family:Times New Roman;
margin:20px auto;
padding:15px;
}
#nav, #nav ul {
background-image:url(../images/tr75.png);
list-style:none;
margin:0;
padding:0;
}
#nav {
height:41px;
padding-left:5px;
padding-top:5px;
position:relative;
z-index:2;
}
#nav ul {
left:-9999px;
position:absolute;
top:37px;
width:auto;
}
#nav ul ul {
left:-9999px;
position:absolute;
top:0;
width:auto;
}
#nav li {
float:left;
margin-right:5px;
position:relative;
}
#nav li a {
background:#AFDCEC;
color:#000;
display:block;
float:left;
font-size:16px;
text-decoration:none;
padding:8px 10px;
}
#nav > li > a {
-moz-border-radius:6px;
-webkit-border-radius:6px;
-o-border-radius:6px;
border-radius:6px;
overflow:hidden;
}
#nav li a.fly {
padding-right:15px;
}
#nav ul li {
margin:0;
}
#nav ul li a {
width:120px;
}
#nav ul li a.fly {
padding-right:10px;
}
#nav li:hover > a, current {
background-color:#659EC7;
color:#000;
}
#nav li.current a {
background-color:#659EC7;
text-decoration:none;
}
#nav li a:focus {
outline-width:0;
}
#nav li a:active + ul.dd, #nav li a:focus + ul.dd, #nav li ul.dd:hover {
left:0;
}
#nav ul.dd li a:active + ul, #nav ul.dd li a:focus + ul, #nav ul.dd li ul:hover {
left:140px;
}
I use this code for highlighting menus. When clicking on submenus, submenu is hidden.
Please help me out.
Thanks,
Shree
I have written a code for a Nav bar. I have menu, sub menu and sub-sub menus. Menu and Sub-menus are working fine. The sub-sub menus are not working. They are expanding vertically instead of horizontally.
The html code is:
<div id="topbar">
<div class="wrapper">
<div id="topnav">
<ul>
<li class="active">Home</li>
<li>Products
<ul>
<li>Laptop & Notebooks
<ul>
<li>Acer</li>
<li>Apple</li>
</ul>
</li>
<li>Smartphone & Tablets</li>
<li>Desktop</li>
<li>Accessories
<ul>
<li>RAM</li>
<li>Casing</li>
<li>Ups & IPS</li>
</ul>
</li>
<li>Brand PC</li>
<li>Clone PC</li>
<li>Camera</li>
</ul>
</li>
<li>IT Solutions
<ul>
<li>Web Developmnet & Hosting</li>
<li>Mobile Application Development
<ul>
<li>Android Platform</li>
<li>Windows Platform</li>
</ul>
</li>
<li>Software Developement</li>
</ul>
<li>Portfolio</li>
<li>Contact Us</li>
</li>
</ul>
</div>
</div>
and the CSS is here :
#topnav{
display:block;
float:left;
width:660px;
margin:0;
padding:0;
list-style:none;
font-size:13px;
font-weight:normal;
font-family:Verdana, Arial, Helvetica, sans-serif;
color:#FFFFFF;
background-color:#000000;
}
#topnav ul, #topnav li{
float:left;
list-style:none;
margin:0;
padding:0;
}
#topnav li a:link, #topnav li a:visited, #topnav li a:hover{
display:block;
margin:0;
padding:15px 20px;
color:#FFFFFF;
background-color:#000000;
}
#topnav ul ul li a:link, #topnav ul ul li a:visited{
border:none;
}
#topnav li.last a{
margin-right:0;
}
#topnav li a:hover, #topnav ul li.active a{
color:#FFFFFF;
background-color:#059BD8;
}
#topnav li li a:link, #topnav li li a:visited{
width:150px;
float:none;
margin:0;
padding:7px 10px;
font-size:12px;
font-weight:normal;
color:#FFFFFF;
background-color:#000000;
}
#topnav li li a:hover{
color:#FFFFFF;
background-color:#059BD8;
}
#topnav li ul{
background:#FFFFFF;
z-index:9999;
position:absolute;
left:-999em;
height:auto;
width:170px;
border-left:1px solid #FFFFFF;
border-bottom:1px solid #FFFFFF;
}
#topnav li ul a{width:140px;}
#topnav li ul ul{margin:-32px 0 0 0;}
#topnav li:hover ul ul{left:-999em;}
#topnav li:hover ul, #topnav li li:hover ul{left:auto;}
#topnav li:hover{position:static;}
#topnav li.last a{margin-right:0;}
/* ----------------------------------------------Column Navigation-------------------------------------*/
#column .subnav{display:block; width:250px; padding:25px; background-color:#F9F9F9; margin-bottom:30px;}
#column .subnav h2{
margin:0 0 20px 0;
padding:0 0 14px 0;
font-size:20px;
font-weight:normal;
font-family:Georgia, "Times New Roman", Times, serif;
color:#666666;
background-color:#F9F9F9;
line-height:normal;
border-bottom:1px dotted #666666;
}
#column .subnav ul{
margin:0;
padding:0;
list-style:none;
}
#column .subnav li{
margin:0 0 3px 0;
padding:0;
}
#column .subnav ul ul, #column .subnav ul ul ul, #column .subnav ul ul ul ul, #column .subnav ul ul ul ul ul{border-top:none; padding-top:0;}
#column .subnav a{
display:block;
margin:0;
padding:5px 10px 5px 20px;
color:#777777;
background:url("../images/blue_file.gif") no-repeat 10px center #F9F9F9;
text-decoration:none;
border-bottom:1px dotted #666666;
}
#column .subnav a:hover{color:#059BD8; background-color:#F9F9F9;}
#column .subnav ul ul a, #column .subnav ul ul ul a, #column .subnav ul ul ul ul a, #column .subnav ul ul ul ul ul a{background:url("../images/black_file.gif") no-repeat #F9F9F9;}
#column .subnav ul ul a{padding-left:40px; background-position:30px center;}
#column .subnav ul ul ul a{padding-left:50px; background-position:40px center;}
#column .subnav ul ul ul ul a{padding-left:60px; background-position:50px center;}
#column .subnav ul ul ul ul ul a{padding-left:70px; background-position:60px center;}
Jsfiddle link: http://jsfiddle.net/98TRb/
Try adding this to your CSS:
#topnav ul ul li:hover ul {left:170px}
See it in action: http://jsfiddle.net/98TRb/1/
#topnav li ul ul li {display:inline-block; margin-left:40px; background-position:40px; text-align:center; border: 1px red solid; background-color: silver;}
Feel free to experiment with this. I changed colors so it would stand out for you.
I wish to add a transition to my current CSS dropdown menu.
I have my "transition: height ease-in-out 500ms;" code all ready to go, I just need to know where to add it.
How I have my menu setup is like so:
<ul id="nav">
<li>
About Us <img style="border:0;" src="/index_files/darrow.png" />
<ul id="accordion">
<li>Who We Are</li>
<li>Contact Us</li>
<li>Join Us For Worship</li>
<li>Meet Our Staff</li>
</ul>
</li>
</ul>
So, what I am wondering is where I would put my transition code in my .css file to affect the "accordion" section. (I can remove the id="accordion" section, that was just there from testing.
All help is appreciated, thank you.
EDIT: Here is the CSS:
#nav {
font-size:20px;
text-align:center;
position:relative;
z-index:500;
display:block;
margin-bottom:20px;
padding:0;
width:950px;
background:#33A1DE;
float:left;
border-bottom:none;
color:white;
-moz-box-shadow: 0px 5px 10px #333333;
-webkit-box-shadow: 0px 5px 10px #333333;
box-shadow: 0px 5px 10px #333333;
}
#nav a:visited, #nav a {
color:white;
}
#nav li a, #nav li {
float:left;
}
#nav > li {
line-height:2em;
width:20%;
list-style:none;
position:relative;
border-top:none;
border-right:1px solid white;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
#nav > li.right {
line-height:2em;
width:20%;
list-style:none;
position:relative;
border-right:none;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
#nav li a {
height:100%;
width:100%;
text-decoration:none;
background:#33A1DE;
}
#nav li a:hover {
background:#000000;
}
/* Submenu */
#nav li ul {
list-style:none;
width:100%;
display:none;
position:absolute;
left:0;
top:100%;
padding:0; margin:0;
}
#nav li ul:last-child {
border-bottom:1px solid white;
}
#nav li:hover > ul {
display:block;
}
#nav li ul li, #nav li ul li a {
float:none;
}
#nav li ul > li {
left:-1px;
text-align:center;
margin:auto;
position:relative;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
_display:inline; /* for IE6... God knows why */
}
#nav li ul li a {
display:block;
border:1px solid white;
border-bottom:none;
}
/* Sub-Submenu */
#nav li ul li > ul {
list-style:none;
display:none;
position:absolute;
}
#nav li ul li:hover ul {
border-left:1px solid white;
z-index:5;
left:0px;
top:0px;
left:100%;
width:200px;
}
#nav li ul li ul:last-child {
border-bottom:1px solid white;
}
#nav li ul li:hover ul.youth {
border-left:1px solid white;
z-index:5;
left:0px;
top:-100%;
left:100%;
width:200px;
box-sizing:border-box;
}
Start by deleting the display:none from to the accordion. Then specify a height to the accordion li elements as well as a transition type.
in the :hover state of the About us li, you specify the new height for the accordion li's.
DEMO
You add that directive on the same rule where the height of the menu changes (not the :hover state).
You'll have to provide us with more details if you want a more detailed answer.
I am using a horizontal menu from cssmenumaker.com which features subitems. I've been trying, but I just don't manage to add subsub-items.
This is the CSS I'm using:
.menu{
border:none;
border:0px;
margin:0px;
padding:0px;
font: 67.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
}
#menu {
position:absolute;
left:250px;
top:0px;
width:750px;
height:35px;
border:0px solid #123456;
}
.menu ul{
background:#000000;
height:35px;
list-style:none;
margin:0;
padding:0;
}
.menu li{
float:left;
padding:0px;
}
.menu li a{
background:#000000 url("images/seperator.gif") bottom right no-repeat;
color:#cccccc;
display:block;
font-weight:normal;
line-height:35px;
margin:0px;
padding:0px 25px;
text-align:center;
text-decoration:none;
}
.menu li a:hover,
.menu ul li:hover a{
background: #2580a2 url("images/hover.gif") bottom center no-repeat;
color:#FFFFFF;
text-decoration:none;
}
.menu li ul{
background:#333333;
display:none;
height:auto;
padding:0px;
margin:0px;
border:0px;
position:absolute;
width:125px;
z-index:200;
/*top:1em;
/*left:0;*/
}
.menu li:hover ul{
display:block;
}
.menu li li {
background:url('images/sub_sep.gif') bottom left no-repeat;
display:block;
float:none;
margin:0px;
padding:0px;
width:125px;
}
.menu li:hover li a{
background:none;
}
.menu li ul a{
display:block;
height:35px;
font-size:12px;
font-style:normal;
margin:0px;
padding:0px 10px 0px 15px;
text-align:left;
}
.menu li ul a:hover,
.menu li ul li:hover a{
background:#2580a2 url('images/hover_sub.gif') center left no-repeat;
border:0px;
color:#ffffff;
text-decoration:none;
}
.menu p{
clear:left;
}
I already added the subsubmenu's to the HTML (which, I believe, is done correctly):
<div id="menu" class="menu">
<ul>
<li><a href="#" >item1</a></li>
<li>item2</li>
<li>item3
<ul>
<li>subitem1</li>
<li>subitem2</li>
<li>subitem3
<ul>
<li>subsubitem1</li>
<li>subsubitem2</li>
</ul>
</li>
<li>subitem4</li>
<li>subitem5</li>
</ul>
</li>
<li>item4</li>
<li>item5</li>
</ul>
Here's the current situation: http://bit.ly/GRJkT5
As you can see, subsubitems 1 and 2 are displayed on top of subitems 4 and 5. How should I edit the CSS?
Thanks in advance!
Frank.
You should consider making use of the > combinator.
Example:
/* instead of... */
.menu li:hover ul{
display:block;
}
/* use... */
.menu li:hover > ul{
display:block;
}
This will ensure that only direct children of the hovered element will be affected by the style.
Use this combinator in the right places, and your problem should be solved.
Your third level submenu is not really getting positioned absolutely so its just appearing over your second level submenu. Properly position it relative to your submenu, use the child selector to display your second level submenu as Kolink suggested and it should work, like so:
CSS
.menu li:hover > ul{
display:block;
}
.menu li {
position:relative;
}
.menu ul ul ul {
position:absolute;
left:100%;
top:0;
}
Ok, small baby-steps here. I added coding for the subsubmenu's (I will condense the code later):
.menu{
border:none;
border:0px;
margin:0px;
padding:0px;
font: 67.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
}
#menu {
position:absolute;
left:250px;
top:0px;
width:750px;
height:35px;
border:0px solid #123456;
}
.menu ul{
background:#000000;
height:35px;
list-style:none;
margin:0;
padding:0;
}
.menu li{
float:left;
padding:0px;
}
.menu li a{
background:#000000 url("images/seperator.gif") bottom right no-repeat;
color:#cccccc;
display:block;
font-weight:normal;
line-height:35px;
margin:0px;
padding:0px 25px;
text-align:center;
text-decoration:none;
}
.menu li a:hover, .menu ul li:hover a{
background: #2580a2 url("images/hover.gif") bottom center no-repeat;
color:#FFFFFF;
text-decoration:none;
}
/* --- START SUBMENU -------------------------------------------------------------- */
.menu li ul{
background:#333333;
display:none;
height:auto;
padding:0px;
margin:0px;
border:0px;
position:absolute;
width:225px;
z-index:200;
/*top:0px;*/
/*left:0px;*/
}
.menu li:hover ul{
display:block;
}
.menu li li {
background:url('images/sub_sep.gif') bottom left no-repeat;
display:block;
float:none;
margin:0px;
padding:0px;
width:225px;
}
.menu li:hover li a{
background:none;
}
.menu li ul a{
display:block;
height:35px;
font-size:12px;
font-style:normal;
margin:0px;
padding:0px 10px 0px 15px;
text-align:left;
}
.menu li ul a:hover, .menu li ul li:hover a{
background:#2580a2 url('images/hover_sub.gif') center left no-repeat;
border:0px;
color:#ffffff;
text-decoration:none;
}
.menu p{
clear:left;
}
/* --- START SUBSUBMENU -------------------------------------------------------------- */
.menu li ul li ul{
background:#333333;
display:none;
height:auto;
padding:0px;
margin:0px;
border:0px;
position:absolute;
width:225px;
z-index:200;
/*top:0px;*/
/*left:0px;*/
}
.menu lu ul li:hover ul{
display:block;
}
.menu li li li {
background:url('images/sub_sep.gif') bottom left no-repeat;
display:block;
float:none;
margin:0px;
padding:0px;
width:225px;
}
.menu li:hover li li a{
background:none;
}
.menu li ul li ul a{
display:block;
height:35px;
font-size:12px;
font-style:normal;
margin:0px;
padding:0px 10px 0px 15px;
text-align:left;
}
.menu li ul li ul a:hover, .menu li ul li ul li:hover a{
background:#2580a2 url('images/hover_sub.gif') center left no-repeat;
border:0px;
color:#ffffff;
text-decoration:none;
}
The result is here: http://bit.ly/Hl9SwM
The subsubmenu's (2.4.1 etc.) are displayed directly when hovering over menu 2, and their location is not correct (should be to the right of submenu 2.4). How can I change that?
Thank you!