Can't Center Nav Div

2019-09-03 16:21发布

问题:

Okay, so I've looked at various posts on StackOverflow addressing the problem of centering a nav div. The solution seems to be:

.menu {
  text-align: center;
}

But no matter what div wrapping around the nav I use this on it does nothing. You can see the problem at http://www.dustinlee.co

I'm using this framework: https://github.com/jbckmn/naked-wordpress

Notice the navigation is on the left hand side. Even more strange, when you resize the window it begins to almost to the center.

Adding even more to my confusion is the fact that it's wrapped in this:

<nav class="site-navigation main-navigation">

Which seems to be associated with nothing in the styles.

回答1:

add this to your css

header nav ul{display:inline-block;}