Been a while since I've made a website and I cant remember a browser safe way of centering a div, eg using say align="center" or whatever it is in IE will not work. Shouldn't be to hard to asnwer
Been a while since I've made a website and I cant remember a browser safe way of centering a div, eg using say align="center" or whatever it is in IE will not work. Shouldn't be to hard to asnwer
Use this:
This is using CSS to apply center effects. You can also set CSS elements like:Code:<div style="text-align:center;">CENTERED CONTENT</div>
Code:.mycenteredcontent { text-align:center; }Code:<div class="mycenteredcontent">CENTERED CONTENT</div>
Last edited by techairlines; 05-17-2010 at 09:02 PM.
Best regards,
Brian Yang - TechAirlines
How am I doing? Click thestar button at the bottom left to rate this post. Thanks.
Terms of Service | Account Portal | Wiki
Is that not only text centering, by centering i meant, say having "body" div to have like a box in the center, not the content withing that div but the div itself
Almost every browser will understand the auto setting for a margin:
If you absolutely feel you need to fully support IE 6, then this hack will work:Code:#div_id { width: 760px; margin: 0 auto; }
Frankly, I'd let IE6 slide these days. Neither CSS hacks nor the available "IE-updating" javascript libraries are worth the bother for niggling little details like horizontal positioning of containers. Your site will still work without the hacks, even if it isn't exactly the same in IE6 as it is in other browsers. And it just may give people a reason to get fundamentally fed up with a browser that has been obsolete for many years.Code:#div_id { width: 760px; left: 50%; margin-left: -380px; }
“Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
"It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)