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>
Written by tommaso
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Tags
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#