Having some problems with a horizontal navigation - html

I have a django app that has a horizontal navigation. For some reason I am having problems creating a drop down menu.
Have a look at both of these images
The first image shows the horizontal navigation. On the left side of the image, there is a menu.
The second image shows when I hover over Storage orders (This is the only link that has a drop down menu.) For some reason the right hand side of the tab seems a bit off. This is because the length of the tab for storage, delivery and collection are different due to the number of words. I want to try to make all of these three tabs the same length if possible.
Another problem that I have is the left hand side menu moves to the right when I move my curser over storage orders.
base_menu.html
<ul id="toc">
<li id="current"><span>Home</span></li>
<li><span>Create quote/order</span></li>
<li><span> Item Search</span></li>
<li><span>Storage orders</span><br/>
<ul class="subnav">
<li><span>Delivery orders</span></li><br/>
<li><span>Collection orders</span></li>
</ul>
</li>
<li><span>Delivery list</span></li>
<li><span>Collection list</span></li>
<li><span>Export for invoicing</span></li>
<li><span>Backup data</span></li>
<li><span>Help</span></li>
</ul>
<br/>
base.css
ul#toc {
height: 2em;
list-style: none;
margin: 0;
padding: 0;
}
ul#toc li{
background:#ffffff url(../images/tab.png);
float: left;
margin: 0 1px 0 0;
}
ul#toc span {
background: url(../images/tab.png) 100% 0;
display: block;
line-height: 2em;
padding-right: 10px;
}
ul#toc a {
color: #000000;
height: 2em;
float: left;
text-decoration: none;
padding-left: 10px;
}
ul#toc a:hover {
background: url(../images/tab2.png);
text-decoration: underline;
}
ul#toc a:hover span {
background: url(../images/tab2.png) 100% 0;
background-position: 100% -120px;
}
ul.subnav {
float:left;
display:none;
position:absolute;
}
ul#toc li:hover .subnav {
display:block;
}
EDIT: #Andres: If I make the change, you can see from the image below, the drop down tab needs to be lowered a bit more. Also, the collection tab is missing as well, but the good thing is the left hand menu does not shift to the right.
Update #Andres: I have removed the tag in the template has made the tab re-appear. Now using margin-top:10px seem to work. Now from the image below, I need to make sure my drop-down box can overlap the delivery header. And I think I may be done.

Try this:
ul#toc {
height: 2em;
list-style: none;
margin: 0;
padding: 0;
}
ul#toc li{
background:#ffffff url(../images/tab.png);
float: left;
margin: 0 1px 0 0;
position:relative;
}
ul#toc span {
background: url(../images/tab.png) 100% 0;
display: block;
padding-right: 10px;
}
ul#toc a {
color: #000000;
float: left;
text-decoration: none;
padding-left: 10px;
}
ul#toc a:hover {
background: url(../images/tab2.png);
text-decoration: underline;
}
ul#toc a:hover span {
background: url(../images/tab2.png) 100% 0;
background-position: 100% -120px;
}
ul.subnav {
float:left;
display:none;
position:absolute;
}
ul#toc li:hover .subnav {
display:block;
}
since your ul.subnav class is still in the flow of things when it pops up it shifts things on the bottom, if you position it absolutely, relative to the parent li it should fix things up.

Related

Flexible vertical menu

I'm working on this vertical menu. I need it to be flexible, so even longer text can be shown (as seen in the middle item). I want to keep the "padding" of the items, but I also want to increase the space between the lines for multi-line items (if I increase line-height, the distance from the edges gets bigger). How can I achieve that without increasing the "padding"? The images I use must have transparent background, so I can't use combination color-image (there is a gradient behind).
<div id="nav-list">
<ul>
<li><span class="button-middle">Button</span><span class="button-bottom"></span></li>
<li><span class="button-middle">Another button</span><span class="button-bottom"></span></li>
<li><span class="button-middle">The longest button in the world, even longer</span><span class="button-bottom"></span></li>
<li><span class="button-middle">Button</span><span class="button-bottom"></span></li>
<li><span class="button-middle">Btn</span><span class="button-bottom"></span></li>
</ul>
</div>
CSS:
* {
border: 0;
margin: 0;
padding: 0;
}
#nav-list {
width: 195px;
}
#nav-list ul {
list-style: none;
}
#nav-list ul li {
display: block;
margin: 5px 2px 0 5px;
font-size: 13px;
}
#nav-list ul li a {
display: block;
background: url('http://i41.tinypic.com/20h4hvp.png') top left no-repeat;
padding-top: 10px;
line-height: 10px;
color: #000000;
text-decoration: none;
}
#nav-list ul li a .button-middle {
width: 183px;
background: #b6b6b6;
padding-left: 5px;
display: block;
}
#nav-list ul li a .button-bottom {
width: 188px;
height: 10px;
background: url('http://i39.tinypic.com/2mrd343.png') top left no-repeat;
display: block;
}
Note: I can't use CSS3 because of its weak browser support.
I think the best you can do is add something like:
span.button-middle {
line-height: 1.2;
}
You could also decrease the line-height of the top and bottom of the button to compensate for the bigger middle section:
span.button-bottom {
line-height: 0.8;
}
Well... after hours of struggle I managed to solve it. I had to use different images, add one more span and use some relative positioning.
http://jsfiddle.net/uNCsp/
<div id="nav-list">
<ul>
<li><span class="button-top"><span class="button-middle">Button</span></span><span class="button-bottom"></span></li>
<li><span class="button-top"><span class="button-middle">Another button</span></span><span class="button-bottom"></span></li>
<li><span class="button-top"><span class="button-middle">Even longer button button button button</span></span><span class="button-bottom"></span></li>
<li><span class="button-top"><span class="button-middle">Button</span></span><span class="button-bottom"></span></li>
<li><span class="button-top"><span class="button-middle">Button</span></span><span class="button-bottom"></span></li>
</ul>
</div>
CSS:
#nav-list {
width: 195px;
}
#nav-list ul {
list-style: none;
}
#nav-list ul li {
display: block;
margin: 5px 2px 0 5px;
font-size: 13px;
}
#nav-list ul li a {
display: block;
color: #000000;
text-decoration: none;
}
#nav-list ul li a .button-top {
background: url('http://i43.tinypic.com/r0urzp.png') top left no-repeat;
display: block;
}
#nav-list ul li a .button-middle {
position: relative;
top: 6px;
background: transparent;
padding: 0 0 0 5px;
display: block; /* IE7 bug */
line-height: 16px;
padding-bottom: 3px;
}
#nav-list ul li a .button-bottom {
width: 188px;
height: 10px;
background: url('http://i44.tinypic.com/15fqbti.png') top left no-repeat;
display: block;
}
#nav-list ul li a:hover .button-top {
background: url('http://i39.tinypic.com/334qfsz.png') top left no-repeat;
}
#nav-list ul li a:hover .button-bottom {
background: url('http://i41.tinypic.com/2ewinti.png') top left no-repeat;
}
There is a problem in IE7 (marked in the code), but I believe I'll solve that quickly.

Styling navigation through CSS

I'm having troubles coming up with a solution to styling my navigation. This is what I want:
And this is a link to what I have so far.
This is supposed to be two separate classes of links on one navigation bar. One set on the left for the logo and other default links, and on the right is for social. I'm just going to need help with the left side for now but I thought I'd explain even further.
On the left side, each link should be centered in their own little block with a border on the left and right being 1px white. On their hover state, the background of their "box" should be white. The logo should be first on the left.
I'm sorry that I'm not able to explain better, but I've done my best. The picture and the link to what I have so far should explain the most.
I think it would be better if the logo was in the CSS instead of the HTML??
CSS:
/* Navigation bar */
#navi {
font-family: Helvetica Neue: Condensed Bold;
font-size: 14px;
color: white;
text-transform: uppercase;
background-color: #1e416f;
height: 30px;
margin: 0 0 20px 0;
padding: 20px 0 0 0;
}
#navi a {
color: white;
margin: 0 0 0 20px;
height: 30px;
}
#navi a:hover {
background: white;
color: #1e416f;
}
HTML:
<!-- NAVIGATION -->
<div id="navi">
<img src="/imgs/navi/caul_white_nav.png">
Directories
Committees
Resources
About
</div>
You can try something like:
#navi img, #navi a {
float: left; /* float next to each other on the left hand side */
}
#navi a { /* use some padding to have some empty space */
padding: 5px;
border-right: 1px solid #ffffff;
}
#navi a:hover { /* on hover, background white on A tags */
background: #ffffff;
}
And than play untill it fits, with the right side you could do the same, inside the nav you can float it to the right. If you want to have a seperate DIV you should also float this #navi to the left and the #social to the right.
If you only use padding on an element (which is blocked) the text will always be centered because the padding left / right are the same.
TIP: If you use floats like this and you want an item to be on a new line. Normally it would be set next to the float. If you use a DIV after the item and do a clear: both; it will be on a new line.
I've written this using your design: http://jsfiddle.net/ninty9notout/v3658/
Just information on what is what here:
On the homepage, use: <h1 class="logo">...</h1> and on all other pages: <div class="logo">...</div>
.logo and #primary-nav are floated left to make them stick to the left side.
All the li and a tags are also floated to the left. Block elements are easier to style than inline elements.
#tools-nav is floated to the right so it sticks to the right side.
I've used text-indent: -9999px; to hide the text for the logo and the would-be icons in the #tools-nav - feel free to add the icons via background property. Set the widths for the icon anchors to whatever width your icons are + 20 (+10px on either side).
And that is that.
The HTML:
<div id="navi">
<h1 class="logo">Name of Site</h1>
<ul id="primary-nav">
<li>Directories</li>
<li>Committees</li>
<li>Resources</li>
<li>About</li>
</ul>
<ul id="tools-nav">
<li class="login">Log In</li>
<li class="email icon">Email</li>
<li class="twitter icon">Twitter</li>
<li class="search icon">Search</li>
</ul>
</div>
The CSS:
#navi {
height: 30px;
background: #1e416f;
font-size: 14px;
color: white;
text-transform: uppercase;
}
.logo {
margin: 0;
padding: 0;
float: left;
}
.logo a {
float: left;
margin: 2px 10px;
width: 36px;
height: 26px;
background: url(http://redsky.incredifull.com/imgs/navi/caul_white_nav.png) left top no-repeat;
text-indent: -9999px;
}
#primary-nav, #tools-nav {
list-style: none;
margin: 0;
padding: 0;
}
#primary-nav li, #primary-nav a,
#tools-nav li, #tools-nav a { float: left; }
#primary-nav a,
#tools-nav a {
color: white;
text-decoration: none;
padding: 0 10px;
border-right: 1px solid white;
line-height: 30px;
}
#primary-nav li:first-child a,
#tools-nav li:first-child a{ border-left: 1px solid white; }
#tools-nav { float: right; }
#tools-nav .icon a {
text-indent: -9999px;
}
#tools-nav .email a { /* image */ }
#tools-nav .twitter a { /* image */ }
#tools-nav .search a { /* image */ }
I think it's what you wanted. Enjoy :)
Use
<img src="/imgs/navi/caul_white_nav.png" style="float: left;">

change <li> background when hover a

i have this menu:
<div class="nav">
<ul>
<li>HOME</li>
<li>AMORTECIMENTO</li>
</ul>
</div>
the normal apearance:
and this is the apearance when users hover the menu:
So, i dont know how to setup the css, assuming i have biggest names on menu like: "AMORTECIMENTO"
Any tips??
i have tried this, but on small names, the menu is cutting the background...
.nav ul li a{
display:block;
font-size:15px;
color:#000;
padding:5px 7px;
background:transparent;
text-decoration:none;
}
.nav ul li:hover{
background:url(../imagens/bola_fundo_menu.png) center no-repeat;
}
My intention is, when user hover the menu item, on the <li> background, apear the basketball, and on <a> tag, the background is going to #FFF but i have small and big names on menu, so i can't set width of <li> and <a> tags... i think
Here is a quick example using pseudo-elements: http://codepen.io/anon/pen/iwerJ
Using the exact HTML you originally posted, with CSS like this:
.nav {
background: #CCC;
font-family: Helvetica, Arial, sans-serif;
line-height: 48px;
margin: 50px auto 0;
width: 90%;
}
.nav ul:after {
clear: both;
content: '';
display: block;
}
.nav ul li {
float: left;
font-size: 14px;
list-style: none;
padding: 0 10px;
position: relative;
}
.nav ul li:hover:after {
/* Replace background with image */
background: #abc123;
/* Optionally remove radius */
border-radius: 30px;
content: '';
display: block;
position: absolute;
top: 50%; left: 50%;
margin-top: -30px;
margin-left: -30px;
height: 60px; width: 60px;
}
.nav a {
color: #333;
display: inline-block;
line-height: 180%;
padding: 0 4px;
position: relative;
text-decoration: none;
z-index: 1;
}
.nav li:hover a { background: #FFF; }
Just set a hover background. Eg:
div.nav li:hover{
background-image: url('basketball.jpg');
}
EDIT:
You've got a lot more issues than just a background image...
You need to vertically center your nav text set a min-width for the
nav cells so that the left and right of the ball aren't cut off
set a solid white background for the anchor tag so the text is actually visible on hover
set a z-index for the anchor tags that's greater
than the center image so that they are all clickable (right now you
can't click the link to the right of the center)
Good luck. I can't write all of that code out for you, but that should send you in the right direction.
on your nav class all you have to do is write your css like this:
.nav ul li:hover
{
background-image:url('yourimage.jpg');
}
To fix the cut-off images, you can simply put a min-width on your .nav li elements. Make sure the value is at least as wide as your background images.
You'll probably also want to add text-align: center.

Make li to cover ul completely without fixed width of li

I have a horizontal menu navigation.
The code is:
<div class="menu-holder">
<ul class="menu">
<li>
Home
</li>
<li>
Profile
</li>
<li>
Billing
<ul class="submenu">
<li>New</li>
<li>Find</li>
</ul>
</li>
<li>
Workspaces
</li>
<li>
Manage Leaves
</li>
<li>
Blogs
</li>
<li>
News
</li>
<li>
Search
</li>
<li>
Albums
</li>
</ul>
</div>
The CSS:
ul.menu {
list-style: none;
padding: 0 20px;
margin: 0;
float: left;
width: 960px;
background: #222;
font-size: 1.2em;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
-khtml-border-radius: 20px;
border-radius: 10px;
behavior: url(CSS3PIE);
}
ul.menu li {
float: left;
margin: 0;
padding: 0 15px 0 0;
position: relative;
}
ul.menu li a{
padding: 10px 5px;
color: #fff;
display: block;
text-decoration: none;
float: left;
}
ul.menu li a:hover{
background: url(Images/topnav_hover.gif) no-repeat center top;
}
ul.menu li span {
width: 17px;
height: 35px;
float: left;
background: url(Images/subnav_btn.gif) no-repeat center top;
}
ul.menu li span.subhover {background-position: center bottom; cursor: pointer;}
ul.menu li ul.submenu {
list-style: none;
position: absolute;
left: 0; top: 44px;
background: #333;
margin: 0; padding: 0;
display: none;
float: left;
width: 170px;
border-radius: 5px;
-webkit-border-radius: 5px;
border: 1px solid #111;
behavior: url(CSS3PIE);
}
ul.menu li ul.submenu li{
margin: 0; padding: 0;
border-top: 1px solid #252525;
border-bottom: 1px solid #444;
clear: both;
width: 170px;
}
html ul.menu li ul.submenu li a {
float: left;
width: 145px;
background: #333 url(Images/dropdown_linkbg.gif) no-repeat 10px center;
padding-left: 20px;
}
html ul.menu li ul.submenu li a:hover {
background: #222 url(Images/dropdown_linkbg.gif) no-repeat 10px center;
}
There is also jQuery has been used to create this navigation.
Now I want to make the li completely cover ui. But without applying fixed width to li. Because there is also another menu item(not in picture) which will be visible depending on the role of the logged in user.
Is it possible?
I believe the best way to solve this is to use display: table/table-cell instead of float: left. Here's a fiddle: http://jsfiddle.net/nk7yY/
Basically, what you'd change in your code is:
ul.menu {
display: table;
width: 100%; /* Tables are not 100% width like block elements */
/* Everything you already had except float: left; which I don't really get why you have to begin with */
}
ul.menu li {
display: table-cell;
/* Everything you already had except float: left; */
}
ul.menu li a {
/* Just remove the float here as well */
}
Edit: This won't work in old IE though, but you can keep the float for them (with a *float hack for example).
Are you saying you have 9 ul.menu li elements and there will some times be a 10th? and that you want all 9 (or 10) together to fill the width of the ul.menu?
or are you talking about the ul.submenu?
Just saying "make the li completely cover ui" also sounds like you want a single <li> to cover the entire width of the navigation ui (assuming its your <ul> and not some other parts of your UI.
Is this what your trying to do? or do you just want all 9 or 10 <li> items to fill the space of the <ul> ?
If so you should probably put a class on <ul class="menu"> which changes depending on the role of the logged in user so that you can adjust the styling accordingly.
Supply a bit more information on what your attempting to do and what browsers your wanting to support i.e. for CSS3.

Want to remove the tab images from my sub-nav

I have a django app that has a horizontal nav. The horizontal nav looks like the image below.
Now what I want to do is edit the sub navigation for storage orders. For both Delivery and collection orders tabs, I want both of these curved tab images removed, and have both of these tab in a retangular background color similar to my tabs. Something like this.
base_menu.html
<ul id="toc">
<li id="current"><span>Home</span></li>
<li><span>Create quote/order</span></li>
<li><span> Item Search</span></li>
<li><span>Storage orders</span><br/>
<ul class="subnav">
<li><span>Delivery orders</span></li><br/>
<li><span>Collection orders</span></li>
</ul>
</li>
<li><span>Delivery list</span></li>
<li><span>Collection list</span></li>
<li><span>Export for invoicing</span></li>
<li><span>Backup data</span></li>
<li><span>Help</span></li>
</ul>
<br/>
base.css
ul#toc {
height: 2em;
list-style: none;
margin-left: 20px;
padding: 0;
position relative;
}
ul#toc li{
background:#ffffff url(../images/tab.png);
float: left;
margin: 0 1px 0 0;
}
ul#toc span {
background: url(../images/tab.png) 100% 0;
display: block;
line-height: 2em;
padding-right: 10px;
}
ul#toc a {
color: #000000;
height: 2em;
float: left;
text-decoration: none;
padding-left: 10px;
}
ul#toc a:hover {
background: url(../images/tab2.png);
text-decoration: underline;
}
ul#toc a:hover span{
background: url(../images/tab2.png) 100% 0;
}
ul.subnav {
float:left;
display:none;
position:absolute;
margin-top:10px;
z-index:999;
padding-top:2px;
}
ul#toc li:hover .subnav {
display:block;
}
Update #Yule I have done what you said, but nothing changes. I have instead wrote.
ul.subnav a {
background: url(../images/squaretab.png)
}
And this gives me this.
Now here U have a grey image on the left, but only partially. I need to remove that green tab completely. How would I do this?
Just set a BG image on subnav li:
ul.subnav li{
background: #ffffff url(../images/squaretab.png) no-repeat;
}
ul.subnav li a{
background: none;
}