html - Horizontal center a div with dynamic width using css -
i've seen million blog posts subject cannot find solution specific problem. set following:
<div id="wrapper" style="position:absolute; max-width:500px; min-width:300px; width:100%"> </div>
how can center wrapper using css. margin:auto won't work.
its style position:absolute
, you're either going have change this:
style="position:absolute; max-width:500px; min-width:300px; width:100%" /* changes to: */ style="margin: 0px auto; max-width:500px; min-width:300px; width:50%" /* width changes there's room center */
or if want keep position:absolute
, you'll have manually set x , y positions javascript.
if mean want center stuff inside it, add text-align: center;
.
Comments
Post a Comment