css to make navigation bar

Reply

Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

css to make navigation bar

 
0
  #1
Sep 22nd, 2006
I am trying to make a navigation bar using a list. Since a list is indented by default, I can't seem to get my list all the way to the left. I have looked at examples of this, but am not sure how they are doing it. Below is what I have
HTML and CSS Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <title>test4</title>
  4. <style type="text/css">
  5. ul { list-style-type: none;
  6. float: left; }
  7.  
  8. li { display: inline;
  9. padding: 2px;
  10. border-style: solid;
  11. border-left-width: 0px;
  12. border-top-width: 1px;
  13. border-bottom-width: 1px;
  14. border-right-width: 1px;}
  15.  
  16. li.first { border-left-width: 1px; }
  17.  
  18. </style>
  19. </head>
  20. <body>
  21. <ul>
  22. <li class="first">first</li><li>second</li><li>third</li><li>fourth</li>
  23. </ul>
  24. </body>
  25. </html>
In a perfect world exceptions would not be needed.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 9
Reputation: narsto is an unknown quantity at this point 
Solved Threads: 1
narsto narsto is offline Offline
Newbie Poster

Re: css to make navigation bar

 
0
  #2
Sep 23rd, 2006
Originally Posted by shanenin View Post
I am trying to make a navigation bar using a list. Since a list is indented by default, I can't seem to get my list all the way to the left. I have looked at examples of this, but am not sure how they are doing it. Below is what I have
HTML and CSS Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <title>test4</title>
  4. <style type="text/css">
  5. ul { list-style-type: none; margin: 0;
  6. float: left; }
  7.  
  8. li { display: inline;
  9. padding: 2px;
  10. border-style: solid;
  11. border-left-width: 0px;
  12. border-top-width: 1px;
  13. border-bottom-width: 1px;
  14. border-right-width: 1px;}
  15.  
  16. li.first { border-left-width: 1px; }
  17.  
  18. </style>
  19. </head>
  20. <body>
  21. <ul>
  22. <li class="first">first</li><li>second</li><li>third</li><li>fourth</li>
  23. </ul>
  24. </body>
  25. </html>
<!-- set ul margin to 0 -->
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: css to make navigation bar

 
0
  #3
Sep 23rd, 2006
I tried that, but does not seem to have any effect. I still am about 6 characters from the left margin.
In a perfect world exceptions would not be needed.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: css to make navigation bar

 
0
  #4
Sep 23rd, 2006
When dealing with "spacing" issues in CSS, always check to ensure that both the margin and the padding properties are properly set for all elements, including all parent/container objects and so on all the way up the tree. In fact, it's best to set margin and padding both to "0" to establish a baseline or "natural" position for everything, and then adjust as needed.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 2
Reputation: azoapes is an unknown quantity at this point 
Solved Threads: 0
azoapes azoapes is offline Offline
Newbie Poster

Re: css to make navigation bar

 
0
  #5
Sep 23rd, 2006
You can always set margin-left for the UL to a negative value... around -40 does it for FireFox. Use JavaScript to vary the margin-left when a user runs IE/FF and that actually makes a solution.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: css to make navigation bar

 
0
  #6
Sep 23rd, 2006
Thanks for the help. I did not even think to check the padding property.
In a perfect world exceptions would not be needed.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1,311
Reputation: vishesh is on a distinguished road 
Solved Threads: 36
vishesh's Avatar
vishesh vishesh is offline Offline
Nearly a Posting Virtuoso

Re: css to make navigation bar

 
0
  #7
Oct 14th, 2006
be careful with margin and padding property and try with different browsers.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 434
Reputation: FC Jamison is on a distinguished road 
Solved Threads: 20
Team Colleague
FC Jamison's Avatar
FC Jamison FC Jamison is offline Offline
Posting Pro in Training

Re: css to make navigation bar

 
0
  #8
Oct 16th, 2006
Take a look at my dropdown tutorial in the tutorials ssection of this site.

It uses list items and contains comments which will tell you what each CSS entry does.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the HTML and CSS Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC