Jump to content

center all DIV


phppaper

Recommended Posts

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;

}

 

Link to comment
https://forums.phpfreaks.com/topic/96274-center-all-div/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/96274-center-all-div/#findComment-493980
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.