我在 WordPress 上有一个菜单,我试图将其居中,但它不会自行居中。如果我将自动放在边距上,它不会执行任何操作,但是当设置固定数字时,它会执行任何操作,但与使用自动不同,它不会完美对齐。
CSS
.menu {
width:auto;
float: left;
display:block;
}
#navcontainer {
display:inline;
padding:0px;
margin: 0px; /*-8px 0 0 10px;*/
list-style:none;
position:relative;
z-index:1;
float:left;
height: 20px;
width: 100%;
}
HTML
<section class="twelve columns text-center" style="background: transparent;">
<div class="menuimg">
<img src="http://fabioide.com/frederiksminde/wp-content/uploads/2014/10/menu.jpg">
</div>
<div id="navcontainer">
<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container' => false, 'theme_location' => 'header-menu' ) ); ?></div>
</section>
最佳答案
HI 现在替换样式表中的两个 css
#navcontainer {
float: none;
display: block;
list-style: none;
position: relative;
z-index: 1;
height: 20px;
width: 100%;
text-align: center;
}
.menu {
width: auto;
float: none;
display: inline-block;
text-align: left;
}
关于html - <ul> 菜单不会居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26293352/