Jump to content


Centering in css


6 replies to this topic

#1 Shifty

    Young Padawan

  • Members
  • Pip
  • 19 posts

Posted 09 August 2005 - 02:32 AM

How do i center my layout in css. I am trying to make my page XHTML 1.0 Strict and it don't allow the center tags. Is there a way with css i can center my whole page ?

Thanks,

- Sh|fty

#2 softLearner

    Young Padawan

  • Members
  • Pip
  • 128 posts

Posted 09 August 2005 - 04:44 AM

The easiest way is to create div, that will act as a container for all your content, then you set the width of how wide you want your site to be, ie 780px now set a margin like this:
margin: 0px auto 0px auto;

If you set the width then you should get margins on the left and the right equal and so your page will align in the center.

#3 Shifty

    Young Padawan

  • Members
  • Pip
  • 19 posts

Posted 09 August 2005 - 05:50 AM

Thanks that fixed that :).

As you may have relised iam new to css and iam used to tables. How would i go about putting in a left nav bar of my site.

Here is a pic of what i have now and what i want,


+ Sh|fty

#4 Jaymz

    Retired P2L Staff

  • Members
  • PipPipPipPip
  • 4,104 posts

Posted 09 August 2005 - 07:40 AM

Place the Div's coding before "Title 2" :)

#5 Shifty

    Young Padawan

  • Members
  • Pip
  • 19 posts

Posted 09 August 2005 - 07:43 AM

I meen to make it take up the whole left side and no letting any content be on the left side but that div.

+ Sh|fty

#6 Jaymz

    Retired P2L Staff

  • Members
  • PipPipPipPip
  • 4,104 posts

Posted 09 August 2005 - 07:46 AM

Oh :)

Put your content in a DIV and give it a fixed width, then put your nav in another div and also give it a fixed width, then put this
float: left;
In the attributes of your navigation div :)

Edited by Jaymz, 09 August 2005 - 07:47 AM.


#7 Shifty

    Young Padawan

  • Members
  • Pip
  • 19 posts

Posted 10 August 2005 - 03:32 AM

That didnt work. I have placed it everyware i can think of on my page but its still alinging at hte bottom but never takeing the whole right side. Its always under the other content or where i put it. Its never takeing the whole right. Also when i added "float: left;" the bottom border wont show up anymore :D

+ Sh|fty





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users