center point of webpage

Discussion in 'CSS' started by Jalpari, Apr 14, 2007.

  1. #1
    how i can create center point of my webpage by using css in dreamweaver MX
     
    Jalpari, Apr 14, 2007 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    Tell us what you're trying to accomplish. Don't ask how to do what you've decided is the solution.

    cheers,

    gary
     
    kk5st, Apr 14, 2007 IP
  3. pixel_dust

    pixel_dust Peon

    Messages:
    151
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    place your content in a wrap-around div:

    css for wrapper div:

    #wrap {
    margin:0 auto;
    width:800px;
    }


    vanessa.
     
    pixel_dust, Apr 15, 2007 IP
  4. mich_alex

    mich_alex Well-Known Member

    Messages:
    511
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    108
    #4
    you need set the body and two div to make things works like charm...here's an example

    body{
    margin:0
    padding:0
    text-align:center;
    }

    #div_wrap {
    margin:0 auto; //auto for left and right and 0 margin for top and left
    width:800px; //important to make the centered work
    }

    #div_container(
    marigin:0
    float:left
    width:800px;
    )

    so the html code should be like this

    <body>
    <div id="wrap">

    <div id="container">
    <!-- content here are all centered now -->
    </div>

    <div>//this one close the wrap
    </body>//this close the body

    try it out ..ok :)
     
    mich_alex, Apr 18, 2007 IP
  5. semantic7

    semantic7 Member

    Messages:
    92
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    48
    #5
    Here is a solution with one div. Set the style for the div as follows...

    top: 50%;
    left: 50%;
    width: 800px;
    height: 400px;
    margin-left: -400px;
    margin-top: -200px;
    position: absolute;

    Setting this will put the div at the center of the page at all times.
     
    semantic7, Apr 20, 2007 IP
  6. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #6
    Using absolute positioning to center an element is very fragile and lacks flexibility. Such a method does not allow for dynamic widths or heights. Should the browser viewport be smaller than the element, 50% of the overflow will be lost and unscrollable.

    cheers,

    gary
     
    kk5st, Apr 20, 2007 IP
  7. pixel_dust

    pixel_dust Peon

    Messages:
    151
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #7
    yeah
    what kk5st said


    vanessa.
     
    pixel_dust, Apr 20, 2007 IP