It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming CSS Forum

New to CSS; having centering problems >_>

New to CSS; having centering problems >_>

Postby Ash44455666 on Mon Apr 21, 2008 8:05 pm

Hello, everyone. I'm new to these forums (new to both HTML and CSS as well), but I can't wait to become a member of this community :D . Anyways, here's my "problem"...

In my Web Design class, I'm working on a business website that is supposed to be 5+ pages. I was trying to use CSS to make my website a little better, but I'm completely new to CSS and don't know very much about it (all the code I've got so far was told to me by the teacher's assistant: a lot of it I don't quite understand). I was trying to start my navigation bar on Friday, and it seemed to be okey. When Monday came, I opened up my index.html file in IE and the navigation bar was all the way to the right, with the leftmost part of it just in the center of the window. Here's the code:

Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>

<head>

<title>CoRe computer Repair</title>
<style type="text/css">
   html,body {
      margin: 0;
      padding: 0;
      height: 100%;
      background-color: #555;
      font-family: helvetica;
   }
   #container {
      width: 100%;
      height: 100%;
      text-align: center;
   }
   .top, .bottom {
      width: 70%;
      margin: auto;
   }
   .top {
      height: 35%;
      background-color: blue;
      text-align: center;
      position: relative;
   }
   .bottom {
      height: 65%;
      background-color: red;
   }
   #logo {
      margin-top: 20px;
   }
   .top table {
      width: 100%;
      border-collapse: collapse;
      margin: 0;
      padding: 0;
      position: absolute;
      border: none;
      bottom: 0;
   }
`   .top table td {
      margin: 0;
      padding: 0;
      text-align: center;
      border: none;
   }
   .top table a {
      display: block;
      width: 100.5%;
      height: 40px;
      line-height: 40px;
      text-decoration: none;
      background-color: green;
      color: white;
      font-weight: bold;
      
   }
   .top table a:hover {
      background-color: darkgreen;
   }
</style>

</head>

<body>
<div id="container">
   <div class="top">
      <img src="images/logo.png" alt="CoRe" id="logo"><br>
      <table>
         <tr>
            <td><a href="#">Home</a></td>
            <td><a href="#">Home</a></td>
            <td><a href="#">Home</a></td>
            <td><a href="#">Home</a></td>
            <td><a href="#">Home</a></td>
         </tr>
      </table>
   </div>
   <div class="bottom">
      
   </div>
</div>

</body>

</html>


Thanks to anyone who helps in advance ^^
Ash44455666
 
Posts: 2
Joined: Mon Apr 21, 2008 7:57 pm

Postby rangana on Tue Apr 22, 2008 2:02 am

First of all, tables was'nt intended for layouts ;)

...Most of all, not for placing your navs side by side within each other, ideal way to do this is using ul :)

See this ammendments:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>

<head>

<title>CoRe computer Repair</title>
<style type="text/css">
   html,body {
      margin: 0;
      padding: 0;
      height: 100%;
      background-color: #555;
      font-family: helvetica;
   }
   #container {
      width: 800px;
      height: 100%;
      text-align: center;
     margin:0px auto;
   }
   .top, .bottom {
      width: 100%;
      margin: auto;
   }
   .top {
      height: 35%;
      background-color: blue;
      text-align: center;
      position: relative;
   }
   .bottom {
      height: 65%;
      background-color: red;
   }
   #logo {
      margin-top: 20px;
   }
   ul{list-style-type:none;margin:0px auto 0px 3px;padding:0px;}
   li{
   float:left;
   margin: 1px;
   padding: 0px;
   width: 97px;
   text-align: center;
   }
  a {
      display: block;
      width: 100.5%;
      height: 40px;
      line-height: 40px;
      text-decoration: none;
      background-color: green;
      color: white;
      font-weight: bold;
       
   }
   a:hover {
      background-color: darkgreen;
   }
   #nav{background:blue;height:50px;margin:0px auto;padding:0px;}
</style>

</head>

<body>
<div id="container">
   <div class="top">
      <img src="images/logo.png" alt="CoRe" id="logo"><br>
   </div>
     <div id="nav">
      <ul>
         <li><a href="#">Home</a></li>
         <li><a href="#">Home</a></li>
         <li><a href="#">Home</a></li>
         <li><a href="#">Home</a></li>
         <li><a href="#">Home</a></li>
         <li><a href="#">Home</a></li>
         <li><a href="#">Home</a></li>
         <li><a href="#">Home</a></li>
      </ul>
   </div>
   <div class="bottom">
       
   </div>
</div>

</body>

<html>


See if it helps :)
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Thank you!

Postby Ash44455666 on Tue Apr 22, 2008 8:16 pm

Thanks Rangana! When I replaced the code with what you had made (including a few minor adjustments I made to make it more how I like it), it worked perfectly :). And I'll try to not use tables (or at least as many) in the future :roll:
Ash44455666
 
Posts: 2
Joined: Mon Apr 21, 2008 7:57 pm

Postby rangana on Wed Apr 23, 2008 12:17 am

NO problem, you're completely welcome ;)

...Get back if you're stumped :)
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 0 guests