0
Hello! I can’t center an ul inside the div CSS
.menu {
clear:both;
position:relative;
width: 100%;
}
.sessoes {
width:1000px;
margin: 0 auto;
}
.menuNav {
width:100%;
text-align:center;
background-color:#3E4095;
}
ul.menuTopo {
text-align:center;
}
ul.menuTopo li {
height:50px;
border-left: #005E9C 1px solid;
}
ul.menuTopo li a {
display:inline-block;
height:50px;
line-height:50px;
vertical-align:middle;
text-align:center;
color: #FFF;
background-color:#3E4095;
}
ul.menuTopo li a:hover {
color: #FFF;
background-color:#CCC;
}
HTML
<div class="menu">
<div class="sessoes">
<nav class="menuNav">
<a class="menuFechar"><img src="../_img/btn-close.png" width="30px;" title="Abrir Menu" /></a>
<ul class="menuTopo">
<li><a href="principal.php" title="Principal">Principal</a>
<li><a href="principal.php?acao=cadastrar" title="Cadastrar">Cadastrar</a>
<li><a href="principal.php?acao=editar" title="Editar">Editar</a>
<li><a href="principal.php?acao=pedidos" title="Pedidos">Pedidos</a>
<li><a href="emails.php?acao=listar" title="E-mails">E-mails</a>
</ul>
</nav>
</div>
</div>
If I do
ul.menuTopo {
width: 100%;
text-align:center;
}
Instead of being 100% div father who is div menuNav, he pushes the Divs that are below her all to the left.
Another problem is the bills:
They are 1000px menuNav (100% of the div sessoes). So I have a right edge of 1 px for each li and a left wedding of 1px for the first li. So 1000 - (5+1) = 994. 994/ 5 = 198.8 px. Can put up to 195 which gives line break. How to fix this?
where? In which style?
– Carlos Rocha
in the ul that you want to centralize
– Nelson Teixeira
margin: auto; (or margin:0 auto;) width:100%; =>All UL was right. And, margin: auto; => nothing happened and remained decentralized in the same place. I put an image in the question.
– Carlos Rocha