phppaper Posted March 15, 2008 Share Posted March 15, 2008 Hello all, how can I center all DIV below, i mean align center all in a html ?? Thanks!! .heading { position:absolute; left:10px; top:18px; width:1000px; height:180px; z-index:1; background-color: #666666; layer-background-color: #666666; border: 1px none #000000; position: absolute; } .neg { position:absolute; left:15px; top:210px; width:240px; height:640px; z-index:1; background-color: #666666; layer-background-color: #666666; border: 1px none #000000; position: absolute; } .b1 { position:absolute; left:270px; top:210px; width:480px; height:200px; z-index:1; background-color: #666666; layer-background-color: #666666; border: 1px none #000000; position: absolute; } .b2 { position:absolute; left:270px; top:425px; width:480px; height:200px; z-index:1; background-color: #666666; layer-background-color: #666666; border: 1px none #000000; position: absolute; } .b3 { position:absolute; left:270px; top:640px; width:480px; height:200px; z-index:1; background-color: #666666; layer-background-color: #666666; border: 1px none #000000; position: absolute; } .r1 { position:absolute; left:765px; top:210px; width:240px; height:200px; z-index:1; background-color: #666666; layer-background-color: #666666; border: 1px none #000000; position: absolute; } .r2 { position:absolute; left:765px; top:425px; width:240px; height:200px; z-index:1; background-color: #666666; layer-background-color: #666666; border: 1px none #000000; position: absolute; } .r3 { position:absolute; left:765px; top:640px; width:240px; height:200px; z-index:1; background-color: #666666; layer-background-color: #666666; border: 1px none #000000; position: absolute; } .fd { position:absolute; left:15px; top:865px; width:1000px; height:180px; z-index:1; background-color: #666666; layer-background-color: #666666; border: 1px none #000000; position: absolute; } Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted March 15, 2008 Share Posted March 15, 2008 You can't, they all use "position: absolute". But you might have some luck in taking the parent div of all of them and have it centered. Don't use position: absolute! (unless it's a rare scenario). Quote Link to comment Share on other sites More sharing options...
thetar Posted March 17, 2008 Share Posted March 17, 2008 use position: relative; Quote Link to comment Share on other sites More sharing options...
calabiyau Posted March 17, 2008 Share Posted March 17, 2008 I fixed width wrapper div around all the other divs might be what you are looking for. <div id="wrapper"> <div ...... <div...... ///all your divs in here </div> then in your css give the wrapper the maximum width you want your content to be and a margin-left: auto; margin-right: auto; position: relative; then you will be absolutely positioning your other divs relative to the wrapper div which will always remain centred on the page, so you will have to go through all your other divs and realign them according to the wrapper, not the edges of the body, if that make sense But like others have said, for the layout it looks like you are trying to make, floats would probably be a better idea, if you want a footer at least Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.