Jump to content

how to align DIV tag centrally without distrubing horizantal alignment


shah

Recommended Posts

Hi,

I have a little problem here. When i try to central align div tag witin a page using STYLE

margin:0 auto; 

it automatically puts some vertical pixels. for example if i put a div within a div tag, and use the above code, it will central align it horizontally but will leave some vertical margin before it starts the new div tag.

 

shortly when ever i use the

.header {
height: 101px;
width: 842px;
background-color: #F33;
}

it will align the header horizontally but it will always leave some vertical space  (that is top:0 or margin-top:0) will not work whatever i do. kindly help me regarding this problem.

 

BR

Syed Arif Ullah Shah

 

 

Well, in my stylesheets, I tend to first wipe out all margins, padding and borders with this declaration:

 

html,body,div,div *{margin:0;padding:0;border:0}

 

It has made a difference for me in site construction. Without it, I have had small display issues, and with it added, it fixed it. Try adding that snippet to your stylesheets and see if that helps.

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.