To center a block in the center, without specifying width?

How can I center the block .top-menu in the center of the parent unit without setting the width or to the width was equal to the content? Why not specify the width occupies the entire width of the parent?
https://codepen.io/UnluckySerivelha/pen/ZvYpeP
June 10th 19 at 15:31
3 answers
June 10th 19 at 15:33
Solution
.nav-inner {
 text-align: center;
}

.top-menu {
 display: inline-block;
}
Thank you! - augustus.Mayer commented on June 10th 19 at 15:36
Contact :) - Geovany_Sawayn commented on June 10th 19 at 15:39
June 10th 19 at 15:35
Why not specify the width occupies the entire width of the parent?

Because div is a block element.

.top-menu {
 margin: 0 auto;
 text-align: center;
}
June 10th 19 at 15:37
Very cool with it's display:flex

Find more questions by tags CSSHTML