tags:

views:

15

answers:

1

I have need to position div with id="center_dv" on center of the div with id="wrapper_dv" and to div wrapper_dv be on center of body. How can I do it ?

 <body>
    <div id="wrapper_dv">
        <div id="center_dv">
            <p>some text</p>
        </div>
    </div>
 </body>
+1  A: 

the most common way is to give the div a width, and to use margin-left and margin-right: auto

If your div is normally having top and bottom margin as 0, then it can be

#center_dv { width: 300px; margin: 0 auto }
#wrapper_dv { width: 600px; margin: 0 auto }

(Giving margin 1 length means apply it to all 4 sides, top, bottom, left and right. Giving margin 2 lengths means apply the 1st length to top and bottom, and the 2nd length to left and right.)

動靜能量
Thanks, this solved my problem !
Jane92