div not centered
I am trying to center a div. Here is my code for it:
border: 2px solid #a1a1a1;
Any ideas on why it won't center, and how to fix this?
<div id="rect" style="text-align:center; margin-right:auto; margin-left:auto;"><? echo $code; ?></div>
You need to give that div a width, something less than 100%, to see any effect from auto margins.
Simple give width in css for example width:900px; so that margin auto can work there.
I tried adding a width, but it seems to have no effect.
What width did you set? How wide is the div's parent? You are not providing enough information for us to debug it.
I have tried both a percentage and px. (50% and 200px).
Get rid of the display:inline-block; css, that's forcing it to the left.
yup, auto-margins do jack on inline-block elements.
Though you've got a perfectly good id, why the inlined STYLE attribute?
Thanks- this worked!
Originally Posted by tracknut
I used this because I had an issue, and it fixed it, but I guess I don't need it anymore.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)