I've made a vertical menu using css. It's a menu with sub menus similar to this one:
http://www.dynamicdrive.com/style/csslibrary/item/suckertree-menu-vertical/
here you can see an example:
It work fine but when I click in one of the sub menus to see the information, the others sub menus disappear, that is the menu stay underneath the text. So if I want to change page by clicking in another sub menu I'm not able, I have to return to home.
Here is my css code:
#menu ul {
list-style: none;
margin: 0;
padding: 3px;
width: 100%;
font-size: 14px;
}
#menu h2 {
color: white;
background: #9370D8;
padding: 4px;
text-align:center;
font-size:15px;
width: 100%;
display: block;
}
#menu a {
color: black;
background: white;
text-decoration: none;
display: block;
font-weight: bold;
width: 100%;
padding:4px;
}
#menu a:hover {
color: black;
background: #eee;
}
#menu li {
position: relative;
}
#menu ul ul ul {
position: absolute;
top: 0;
left: 100%;
width: 100%;
}
div#menu ul ul ul,
div#menu ul ul li:hover ul ul
{display: none;}
div#menu ul ul li:hover ul,
div#menu ul ul ul li:hover ul
{display: block;}
and html code:
<div id="menu">
<ul>
<li><h2>Browse</h2>
<ul>
<li>Districts</li>
<li><a href="/browse/time/" >Time</a></li>
</ul>
</li>
</ul>
<ul>
<li><h2>Analyze</h2>
<ul>
<li>Co-occurrence
<ul>
<li><a href="/analyse/co-occurrence/percentage" >Percentage</a></li>
<li><a href="/analyse/co-occurrence/regions" >Regions</a></li>
</ul>
</li>
<li>Geographical
<ul>
<li>Districts</li>
<li>Citizenship</li>
</ul>
</li>
</ul>
</div>
For example I would use the link above. If I click on sub item 2.1 from folder 2, I will see some page with information.
Now I want to see the sub item 1.1 from folder 1, but my problem is when I click in one of the sub menus I'm not able to see the sub item 1.1, so if I want to click in sub item 1.1 I have to return to the main page
the problem is the following:
Any help would be appreciate :)
Thanks!
The problem was the z-index.
I read the tutorials and the front page had an z-index: -1;
and the menu had a z-index: 1;
So the following doesn't work, you have to set something like this:
body
{
z-index: 1;
}
sub-menu
{
z-index: 999;
}
Related
I have a nav that holds a ul with several ils. The problem is that im unable to get rid of the ul's first and last child's divider.
here's a demo: http://jsfiddle.net/Rvs3C/1/
i've added this code to my CSS file but seems like it makes no difference:
nav ul a li:first-child{
content: none;
}
nav ul a li:last-child{
content: none;
}
You markup is wrong. The corret way is <a> tag being the children of tag <li>.
The way you made the correct selector would:
nav ul a:first-child li{
content: none;
}
nav ul a:last-child li{
content: none;
}
But remembering, this is not the right way to do.
The correct is change you html to:
<ul class="showing">
<li>home</li>
...
As mentioned elsewhere your HTML structure is off, li must me a direct child of ul, no other element as a child is valid. With this said, you also need to change your selectors per the below.
Updated Fiddle
HTML
<nav>
<ul class="showing">
<li>home
</li>
<li>about me
</li>
<li>content
</li>
<li>browse
</li>
<li>rate
</li>
<li class="nav_arr"><img src="http://www.irvinewelsh.net/images/arrow-left.png" />
</li>
</ul>
</nav>
CSS
nav {
margin-right: 150px;
}
nav ul {
background-color: #494A4C;
overflow: hidden;
text-align: right;
}
nav li img {
margin-left: 20px;
vertical-align: top;
}
nav ul li a {
color: white;
text-decoration: none;
font-family:arial;
font-size: 14px;
padding: 0px;
font-weight: bold;
}
nav ul li:first-child:before {
content: none;
}
nav ul li:last-child:before {
content: none;
}
nav li:before {
content:"|";
padding: 5px;
font-weight: bold;
color:lightblue;
font-size: 20px;
}
nav ul li {
display: inline-block;
}
I'm a relative newbie and I'm having trouble following the css for my nav. I need to do 2 things:
1) run my sub menu inline
2) hide my sub-sub nav, and show it inline as well.
Here is the test site: http://gbetza.mydomain.com/webservice2/test/Basso56/test/home.html
Here is the CSS: http://gbetza.mydomain.com/webservice2/test/Basso56/test/css/style%20-%20Copy.css
I'm having trouble understanding which class I need to adjust as well as how.
Thank you
Copy + Paste from a similar answer of mine.
I have created a really simple implementation of this. It is barebones so that you can get a real easy look at the basic concept.
In the fiddle here: http://jsfiddle.net/WS3QQ/2/
HTML - Note how the sub-menus are nested
<div id="nav">
<ul>
<li>Top Menu
<ul>
<li>Sub-Menu</li>
<li>Sub-Menu</li>
<li>Sub-Menu</li>
</ul>
</li>
<li>Top Menu</li>
<li>Top Menu</li>
<li>Top Menu</li>
</ul>
</div>
CSS - note how you can easily target the sub-menus (#nav li li). By default the sub-menu li is hidden (display:none). When the li is hovered over, the sub menu li is shown (display:block).
#nav ul { list-style-type: none; margin: 0; padding: 0; }
#nav li { float: left; }
#nav li li { clear: left; display: none; }
#nav li:hover li { display: block; }
#nav li:hover a { background: #111; }
#nav li a { background: #333; padding: 10px; display: block; color: #FFF; font-weight: bold; text-decoration: none; }
#nav li a:hover { background: #3914AF; }
I tried solving this using some tips from this site but it doesn't seem to work for me. I have a website http://apartmanimikzaton.com/paintball/index.php, and I want to create a drop down menu like from the navigation.
EDIT: I didn't add it right now, but the thing I want to get is drop down menu text on hover.
This is my navigaton:
<ul class="navigation">
<li id="navigation-1"> O nama </li>
<li id="navigation-2"> Oprema </li>
<li id="navigation-3"> Tereni
<ul>
<li> Lokacija 1 </li>
<li> Lokacija 2 </li>
</ul>
</li>
<li id="navigation-4"> Galerija </li>
<li id="navigation-5"> Cjenik </li>
<li id="navigation-6"> O Paintballu </li>
<li id="navigation-7"> Teamovi </li>
<li id="navigation-8"> Webshop </li>
</ul>
And this is my css:
.navigation {background: url(images/layout/navigation.jpg) no-repeat; width: 980px; height: 57px; margin: 0 0 10px 0; padding: 0;}
.navigation li, .navigation a {height: 57px; display: block;}
.navigation li {float: left; text-indent: -9999em; position: relative;}
.navigation ul ul{
position:absolute;
left: 0;
top: 100px; /* height of the parent list item */
display:none; /* hide it */
}
.navigation li:hover > ul{ /* show it when mouse is over the parent list item */
display:block;
}
I'm doing something wrong so any tips would be appreciated.
I took the time to analyze your code, and here's what I can help you with for now.
First of all, insert these styles into your CSS:
ul.navigation li ul{
background: none repeat scroll 0 0 #000000;
display:none;
padding: 0;
position: absolute;
top: 57px;
width: 117px;
z-index: 6;
}
On the following styles:
.navigation li {
float: left;
position: relative;
text-indent: -9999em;
width: 100%;
}
The text-indent: -9999em; is affecting the text of the drop down menu you want to insert. I suggest you remove it. If you don't wish to display the text over your menu icons, you can simply do it like this on your link:
I don't think this approach will work:
.navigation li:hover > ul{ /* show it when mouse is over the parent list item */
display:block;
}
Try this instead and see if it works:
.navigation li:hover ul{
display:block;
}
That should at least help you a bit, can't really tell if that's what you are intending to do. Give a response if you manage to accomplish what you wanted.
Cheers,
Artur Balestro
Remove this:
.navigation li:hover > ul{ /* show it when mouse is over the parent list item */
display:block;
}
And Add this
.navigation li:hover ul{ /* show it when mouse is over the parent list item */
display:block;
}
There are some unnecessary styles in there that need cleaning up, but if you're wanting a quick fix:
.navigation > li:hover > ul,
.navigation > li:hover > ul > li,
.navigation > li:hover > ul > li > a {
text-indent: 0;
display: block;
z-index: 999;
background: #fff;
}
Hello I'm new to html & css and I have a problem. I made a navbar and wanted to show the user on wich page he was by changing the background-color in the navbar. But for some reason this doens't work very well. Please help me.
This is the css code I use for the navbar:
#nav{
width: 60%;
display: inline-block;
text-align: right;
float: right;
}
/* unorded list */
#nav ul{}
#nav ul li{
display: inline-block;
height: 62px;
}
/* text in blokken */
#nav ul li a{
padding: 20px;
background: orange;
color: white;
}
#nav ul li a:hover{
background-color: #ff1e42;
box-shadow: 0px 1px 1px #666;
text-decoration: underline;
}
#nav ul li #inuse {
background-color: #ff1e42;
}
my html code looks like this:
<div id="nav">
<ul>
<li><a class="inuse" href="../html/index.html" >Home</a></li>
<li><a href="../html/kleding.html" >Kleding</a></li>
<li><a href="../html/bestel.html" >Bestellen</a></li>
<li>Contact</li>
<li><a href="../html/vragen.html" >Vragen</a></li>
</ul>
</div>
Thanks in advance.
try:
#nav ul li a.inuse{/* in use css */}
instead of:
#nav ul li #inuse{}
hope that helps
I would like to add a CSS-only drop down menu to a site. I am able to do this with just one drop, but am having trouble with adding another tier to the menu.
I am able to get the list to hide initially, but when the trigger is hovered over, the entire list becomes visible, instead of just the first tier of the drop down list.
This is part of the list:
<ul id="DealerNav">
<li>Order from your dealer
<ul>
<li>BFC Syringe (empty)
<ul>
<li>Atlanta Dental</li>
<li>Benco Dental</li>
</ul>
</li>
<li>BFC Complete
<ul>
<li>Practicon Dental</li>
</ul>
</li>
<li>Vaccu•sil Heavy Body
<ul>
<li>Atlanta Dental</li>
<li>Benco Dental</li>
<li>Burkhart Dental</li>
</ul>
</li>
</ul>
And, this is the CSS that controls it:
#DealerNav { margin: 0; padding: 0; font-weight: bold; }
#DealerNav li { list-style-type: none; font-size: 100%; position: relative; margin-left: -3em; }
#DealerNav li li { margin: 2px 0; }
#DealerNav li ul { display: none; }
#DealerNav a.first { width:100%; color: #555; background-color: #FFF; margin-left: 2.5em; }
#DealerNav a { display:block; width: 12em; padding: .5em; background-color: #CEF; color: #FFF; }
#DealerNav a:hover { color: #555; }
#DealerNav a:hover.first { color: #CEF; }
#DealerNav li:hover ul { display: block; }
#DealerNav ul ul { margin-left:10em; margin-top: -2.25em; }
Is this too complicated to ask help on?
The page in question is temporarily at:
http://www.hodentalcompany.com/pages/syringe2.html
The menu is at the bottom of the right column on the text, "Order from your dealer"
Thanks everyone for any help!
Change this:
#DealerNav li:hover ul { display: block;}
to this:
#DealerNav li:hover > ul { display: block; }
You only want the first child UL to show, not all of them.,
Like this?
http://jsfiddle.net/kboucher/nrAPu/