Rollback999

What's the Easiest Way to Center a Div That's Been Dynamically Generated?

Asked by Rollback999 2 years ago div dynamic


Neil Monroe
0
 
If it's within a fixed-width container add some CSS:

#dynamicDiv {
    width: 400px;
    margin: 0 auto;
}

If it's not, or the contents changes, you could use a min-width/max-width and the same technique with margins above. If you need to support IE6, then you may need to set an explicit width for this browser using conditional comments or a separate stylesheet or filter rule.

#dynamicDiv {
    max-width: 400px;
    margin: 0 auto;
}
/* For IE6 (using CSS filter) */
* html #dynamicDiv {
    width: 400px;
    margin: 0 auto;
}

by Neil Monroe 2 years ago

Answer this question

What's the Easiest Way to Center a Div That's Been Dynamically Generated?

0 errors found:

 
0