User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 374,020 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,742 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 6292 | Replies: 7
Reply
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
shanenin shanenin is offline Offline
Posting Whiz in Training

css to make navigation bar

  #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>
  <head>
	<title>test4</title>
	<style type="text/css">
	  ul { list-style-type: none;
		   float: left; }
	
	  li { display: inline;
		   padding: 2px;
		   border-style: solid;
		   border-left-width: 0px;
		   border-top-width: 1px;
		   border-bottom-width: 1px;
		   border-right-width: 1px;}
		   
	   li.first { border-left-width: 1px; }
	
	</style>
  </head>
  <body>
  <ul>
	<li class="first">first</li><li>second</li><li>third</li><li>fourth</li>
  </ul>
  </body>
</html>
In a perfect world exceptions would not be needed.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2006
Posts: 9
Reputation: narsto is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
narsto narsto is offline Offline
Newbie Poster

Solution Re: css to make navigation bar

  #2  
Sep 22nd, 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>
  <head>
    <title>test4</title>
    <style type="text/css">
      ul { list-style-type: none; margin: 0;
           float: left; }
 
      li { display: inline;
           padding: 2px;
           border-style: solid;
           border-left-width: 0px;
           border-top-width: 1px;
           border-bottom-width: 1px;
           border-right-width: 1px;}
 
       li.first { border-left-width: 1px; }
 
    </style>
  </head>
  <body>
  <ul>
    <li class="first">first</li><li>second</li><li>third</li><li>fourth</li>
  </ul>
  </body>
</html>

<!-- set ul margin to 0 -->
Reply With Quote  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: css to make navigation bar

  #3  
Sep 22nd, 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  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: css to make navigation bar

  #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  
Join Date: Sep 2006
Posts: 2
Reputation: azoapes is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
azoapes azoapes is offline Offline
Newbie Poster

Re: css to make navigation bar

  #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  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: css to make navigation bar

  #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  
Join Date: Oct 2006
Location: India
Posts: 1,288
Reputation: vishesh is on a distinguished road 
Rep Power: 4
Solved Threads: 32
vishesh's Avatar
vishesh vishesh is offline Offline
Nearly a Posting Virtuoso

Re: css to make navigation bar

  #7  
Oct 14th, 2006
be careful with margin and padding property and try with different browsers.
Reply With Quote  
Join Date: Jun 2004
Location: Hemet, CA
Posts: 427
Reputation: FC Jamison is on a distinguished road 
Rep Power: 5
Solved Threads: 17
Colleague
FC Jamison's Avatar
FC Jamison FC Jamison is offline Offline
Posting Pro in Training

Re: css to make navigation bar

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb HTML and CSS Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the HTML and CSS Forum

All times are GMT -4. The time now is 11:13 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC