Last Updated: February 25, 2016
·
168
· frontnerd

Center a no-width element with Css

It will center an element who has no "width" defined.

Ok, it needs a wrapper but width 100% works really fine (IE8 too).


.ugly-wrapper {
width: 100%;
text-align: center; // this will center the child element
position: relative;
.centered {
display: inline-block;
margin: 0 auto;
position: relative;
}
}
</pre>