Question:

Aligning Div Tags with CSS?

by  |  earlier

0 LIKES UnLike

Is there a way to align a div in bottom , top or middle of a page ?

 Tags:

   Report

2 ANSWERS


  1. <div id="name" style="position:absolute; top:#px; left:#px; height:#px; width="#px;">content </div>

    I don't think you can put it in the middle of the page, really because everyone's monitor is different from yours and their middle isn't EXACTLY your middle.


  2. Only with absolute positioning, which takes the DIV out of the flow of any other elements...

    Unless the DIV is the main container element...

    Use a trick (kind of ugly):

    div#main {

    position: absolute;

    width: 800px;

    height: 400px;

    top: 50%;

    margin-top: -200px;

    left: 50%;

    margin-left: -400px;

    }

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.