The following HTML looks as required in Firefox 2 & 3 and IE7. The Left button is on the left, the Right button is on the right, and the text in the middle is…in the middle!
However on IE6 the Left button is misaligned – it appears center-aligned.
Can anyone suggest why??
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <title>Layout problem!</title> <style type='text/css'> DIV#Footer { padding: 10px; color: #fff; background-color: #484848; position: relative; text-align: center; } DIV#Footer INPUT { margin: 5px 15px; position: absolute; top: 0px; } DIV#Footer INPUT.right { right: 0px; } DIV#Footer INPUT.left { left: 0px; } </style> </head> <body> <div id='Footer'> <input class='left' type='button' value='Left' /> Some text in the middle <input class='right' type='button' value='Right' /> </div> </body> </html>
(I have been using the IE Developer tool to try and analyse and fix this, to no avail…)
You must trigger the
hasLayoutproperty (an IE thing…) of#footer. Width and height trigger it, if you don’t want to set a width or height, you can use the IE-onlyzoomproperty in CSS.IIRC, in IE, elements have two different layout behaviors, one if
hasLayoutistrue, and another if it’sfalse. Making sure that it’s set totruecan fix a lot of weird layout issues like this one.