Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Aligning with CSS

Aligning with CSS

Scheduled Pinned Locked Moved Web Development
csshelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    srt7
    wrote on last edited by
    #1

    hello all, My page was built using

    's from CSS. Now I want the whole page to be centered but I am not able to do it. In my CSS file I have entered: body{ text-align:center} but nothing goes on. Can anyone help me out here please. Regards, Tiruvan

    T D 2 Replies Last reply
    0
    • S srt7

      hello all, My page was built using

      's from CSS. Now I want the whole page to be centered but I am not able to do it. In my CSS file I have entered: body{ text-align:center} but nothing goes on. Can anyone help me out here please. Regards, Tiruvan

      T Offline
      T Offline
      theJazzyBrain
      wrote on last edited by
      #2

      One way of doing it is to put all your content into one DIV tag. Then you need to align the outer DIV as such: DIV.master {position:absolute; width:600px; left:50%; left-margin:-300px;} Notice that the left-margin must be minus half of the width in order to align it in the center. This also works for horizontal aligning. Ofcourse, if you have used ABSOLUTE positioning for your content you will have to change it to RELATIVE in order to use as origin the top left coords of the master div instead of the top left coords of the BODY. Hope that I helped. theJazzyBrain

      Excelence is not an act, but a habbit

      Aristotle

      1 Reply Last reply
      0
      • S srt7

        hello all, My page was built using

        's from CSS. Now I want the whole page to be centered but I am not able to do it. In my CSS file I have entered: body{ text-align:center} but nothing goes on. Can anyone help me out here please. Regards, Tiruvan

        D Offline
        D Offline
        DFU23
        wrote on last edited by
        #3

        try something like this on a containing DIV (or whatever elements suits the need):

        #container {
        position: relative;
        width: 800px;
        margin-left: auto;
        margin-right: auto;
        text-align: left;
        border: 0px;
        }

        Wally Atkins
        Newport News, VA, USA

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups