Web Design Forum: Slight problem with navagation using CSS - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Slight problem with navagation using CSS

#1 User is offline   chrisfreelance 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 21
  • Joined: 02-April 09
  • Reputation: 0
  • Gender:Male
  • Location:Belfast, N.Ireland.
  • Experience:Beginner
  • Area of Expertise:I'm Learning

  Posted 10 April 2009 - 11:25 AM

Hello everyone.

I've created an unordered list and converted it to a navigation bar using CSS. My problem is is that the navigation bar just sticks to the left of the page vertically. What I want it to do is sit horizontally across the page at the top above my conent.

I've primarily designed websites using Dreamweaver and I'm looking to get stuck into the coding aspect of it now.

Thanks everyone!


Below is my code:

<html>

<head>

<title>yesweb.co.uk - coming soon.</title>

<meta name="Keywords" content="" /> 

</head>

<link rel="stylesheet" type="text/css" href="style.css"/>



<body>

<div id="nav">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Clients</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact us</a></li>
</ul>
</div>

<div id="main">

<h1>www.yesweb.co.uk</h1>
<h2>Freelance web development by</h2> 
<h2>Chris Kernaghan..</h2>

<p>This is just a wee test to see if this text stays within the box area in the centre of the page. I hope that it does!</p>

<p>This is just a wee test to see if this text stays within the box area in the centre of the page. I hope that it does!</p>

<p>This is just a wee test to see if this text stays within the box area in the centre of the page. I hope that it does!</p>

<p>This is just a wee test to see if this text stays within the box area in the centre of the page. I hope that it does!</p>

<p>This is just a wee test to see if this text stays within the box area in the centre of the page. I hope that it does!</p>

<p>This is just a wee test to see if this text stays within the box area in the centre of the page. I hope that it does!</p>

<p>This is just a wee test to see if this text stays within the box area in the centre of the page. I hope that it does!</p>

<p>This is just a wee test to see if this text stays within the box area in the centre of the page. I hope that it does!</p>

<img src="logo1.gif" alt=""/>

</div>

</body>

</html>



p {color: white}
h1 {color: red}
h2 {color: red}

#nav ul {
list-style: none;
padding: 0;
margin: 0;
float: left;
margin: 0 0.15em;
}

#nav ul a
{
background: url(butt.jpg) #fff bottom left repeat-x;
height: 2em;
line-height: 2em;
float: left;
width: 9em;
display: block;
border: 0.1em solid #dcdce9;
color: #0d2474;
text-decoration: none;
text-align: center;
}

body {
background-color: #000000;
background-repeat:repeat;
font-family: "ariel", helvetica, times;
background-image: url("bg.jpg");
background-repeat: no-repeat;
background-position: 50% 20%;

}

#main {

margin-left: 5%;
margin-right: 5%;
margin-top: 55%;
margin-bottom: auto;
margin: 0% auto;
width: 40%;
padding: 0.5em;
background-color: #000000;
clear: both;
}

0

#2 User is offline   mr p 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 325
  • Joined: 09-December 08
  • Reputation: 6
  • Gender:Male
  • Location:London
  • Experience:Advanced
  • Area of Expertise:Designer/Coder

Posted 10 April 2009 - 11:37 AM

here's the basic code of how i do it...


ul.menu {list-style: none; float: left; position: relative; width: 500px}
ul.menu li { float: left; }
ul.menu li a {text-align: center; display: block; width: 100px }



i think it's because you're not floating the list items.
0

#3 User is offline   chrisfreelance 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 21
  • Joined: 02-April 09
  • Reputation: 0
  • Gender:Male
  • Location:Belfast, N.Ireland.
  • Experience:Beginner
  • Area of Expertise:I'm Learning

Posted 10 April 2009 - 11:48 AM

Thanks very much, that seems to have done the trick.

#nav ul  {list-style: none; float: left; position: relative; width: 500px; margin-left: 35%;}
#nav ul a{ float: left; }
#nav ul a {text-align: center; display: block; width: 100px; }


:)
0

#4 User is offline   mr p 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 325
  • Joined: 09-December 08
  • Reputation: 6
  • Gender:Male
  • Location:London
  • Experience:Advanced
  • Area of Expertise:Designer/Coder

Posted 10 April 2009 - 12:11 PM

View Postchrisfreelance, on Apr 10 2009, 12:48, said:

Thanks very much, that seems to have done the trick.

#nav ul  {list-style: none; float: left; position: relative; width: 500px; margin-left: 35%;}
#nav ul a{ float: left; }
#nav ul a {text-align: center; display: block; width: 100px; }


:)



no worries, but you don't need 2 sets of styles for ul a - just combine them and pop float: left; in with the rest.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users