A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Engineering
»
HTML, CSS and JavaScript
Author
HTML/CSS: navigation bar
qunfeng wang
Ranch Hand
Joined: Jan 28, 2005
Posts: 407
posted
Dec 04, 2009 01:00:55
0
I've met problems when implementing navigation with<table> & some CSS.
I can't make a gap between each tab when set border-spacing:0px;
There is a little gap between table and <h r>
The original problem and image is at:
http://www.stanford.edu/class/cs142/cgi-bin/project.php?project=1
Below is my implementation:
HTML
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>CS 142 Project 1, Problem 2</title> <link rel="stylesheet" type="text/css" href="p2.css" /> </head> <body> <table> <tr> <td class="left"><div/></td><td class="navbar"><a><span class="text">Inventory</span></a></td><td class="right"></td> <td class="left"><div/></td><td class="navbar"><a><span class="text">Order Information</span></a></td><td class="right"></td> <td class="left"><div/></td><td class="navbar"><a><span class="text">Account</span></a></td><td class="right"></td> <td class="left"><div/></td><td class="navbar"><a><span class="text">Shippers</span></a></td><td class="right"></td> <td class="left"><div/></td><td class="navbar"><a><span class="text">Suppliers</span></a></td><td class="right"></td> </tr> </table> <hr id="line"/> </body> </html>
CSS
table { border-spacing:0px; margin-bottom:0px; border-bottom:0px; } td { margin-bottom:0px; border-bottom:0px; } .navbar{ background-image:url(mid.gif); } .left{ background-image:url(left.gif); } .right{ background-image:url(right.gif); } .text{ font-family:tahoma; font-size:13px; margin:5px; } #line{ margin-top:0px; border-top:0px; color:#cccccc; } a:link { text-decoration:none; } a:hover { color:#cc6600; cursor:pointer; } a:active { color:black; font-weight:bold; } .navbar:active { background-image:url(mid-selected.gif); } .left:active { background-image:url(left-selected.gif); } .right:active { background-image:url(right-selected.gif); }
To be or not to be. It's a question.
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
6
posted
Dec 04, 2009 05:50:56
0
You should not be using a table for navigation menus.
You really should be using an unordered list:
http://css.maxdesign.com.au/listamatic/
Eric
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
I like...
posted
Dec 04, 2009 07:08:30
0
And it'd probably be better to use a border rather than an HR if you're trying to get a line underneath a DIV.
ahmer afzal
Greenhorn
Joined: Oct 12, 2009
Posts: 3
posted
Feb 18, 2010 00:34:06
0
------------------ Html -------------------
<div class="MainClassForNavigation"> <ul> <li class="active"><a class="active" href="#">Home</a></li> <li><a href="#">Data</a></li> <li><a href="#">Portfolio</a></li> <li><a href="#">Contant Us</a></li> </ul> </div>
---------------- CSS -----------------------
body { behavior:url("Script/csshover3.htc"); /*For Ie 6 Mouse Hover Problem Solved*/ /* csshover3 file uploaded from that URL:http://www.enrap.org/csshover3.htc/view */ } .MainClassForNavigation { } .MainClassForNavigation ul { padding:0px; margin:0px; } .MainClassForNavigation li { float:left background-image:url(RightAlignBackgroundImage); background-position:top right; background-repeat:no-repeat; margin:0 1px 0 0; } .MainClassForNavigation a,.MainClassForNavigation a:visited,.MainClassForNavigation a:link { background-image:url(LeftAlignBackgroundImage); background-position:top left; background-repeat:no-repeat; } .MainClassForNavigation li.active { background-image:url(RightAlignActiveBackgroundImage); background-position:top right; background-repeat:no-repeat; } .MainClassForNavigation a.active { background-image:url(LeftAlignActiveBackgroundImage); background-position:top left; background-repeat:no-repeat; } .MainClassForNavigation li:hover { background-image:url(RightAlignHoverBackgroundImage); background-position:top right; background-repeat:no-repeat; } .MainClassForNavigation a:hover { background-image:url(LeftAlignHoverBackgroundImage); background-position:top left; background-repeat:no-repeat; }
Code was Perfect in All the Browsers Without Table
Regards
Ahmer Afzal
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
I like...
posted
Feb 18, 2010 05:13:25
0
... but hopefully they've already fixed their problem from 2.5 months ago.
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: HTML/CSS: navigation bar
Similar Threads
converting html to pdf
multiple lines in button
Problem hiding div within div
problem in running a servlet
Firefox is driving me nuts - can't control td height
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter