2
Good Morning!
See the figure below.
I have the following css
ul.listaTopo, ul.listaRegistros {
clear:both;
}
ul.listaTopo {
background-color:#000;
color:#FFF;
}
ul.listaTopo li, ul.listaRegistros li {
display:inline-block;
height:50px;
line-height:50px;
vertical-align:middle;
text-align:center;
font-weight:bold;
}
And the following html
<h1 class="h1Centralizado">Listagem de Clientes</h1><br />
<div class="divLista" style="width:800px">
<ul class="listaTopo">
<li class="listaLi" style="width:300px">NOME</li>
<li class="listaLi" style="width:200px">BAIRRO</li>
<li class="listaLi" style="width:100px">BLOQUEIO</li>
<li class="listaLi" style="width:100px">EDITAR</li>
<li class="listaLi" style="width:100px">EXCLUIR</li>
</ul>
<ul class="listaRegistros">
<li style='text-align:left; width:300px; background-color:#CCC; color:#FFF'>José Mário
</li>
<li style='text-align:left; width:200px; background-color:#CCC; color:#FFF'>São</li>
<li style='text-align:center; width:100px; background-color:#CCC; color:#FFF'><a href='?acao=bloqdes&bloq=s&idCliente=1' onclick="return verifica('Deseja Bloquear este Cliente?')" '><img src='_img/bloquear.png' height=30px title='Bloquear Cliente' /></a>
</li>
<li style='text-align:center; width:100px; background-color:#CCC; color:#FFF'><a href='clientesEditar.php?acao=form&idCliente=1'><img src='_img/editar.png' height='30px' title='Editar Cliente' /></a>
</li>
<li style='text-align:center; width:100px; background-color:#CCC; color:#FFF'><a href='?acao=excluir&idCliente=1' onclick="return verifica('Deseja Excluir este Cliente?')" '><img src='_img/excluir.png' height='30px' title='Excluir Cliente'/></a>
</li>
</ul>
<ul class='listaRegistros'>
<li style='text-align:left; width:300px; background-color:#FFF; color:#CCC'>Carlos Aberto Ferreira Rocha
</li>
<li style='text-align:left; width:200px; background-color:#FFF; color:#CCC'>São</li>
<li style='text-align:center; width:100px; background-color:#FFF; color:#CCC'><a href='?acao=bloqdes&bloq=s&idCliente=2' onclick="return verifica('Deseja Bloquear este Cliente?')" '><img src='_img/bloquear.png' height=30px title='Bloquear Cliente' /></a>
</li>
<li style='text-align:center; width:100px; background-color:#FFF; color:#CCC'><a href='clientesEditar.php?acao=form&idCliente=2'><img src='_img/editar.png' height='30px' title='Editar Cliente' /></a>
</li>
<li style='text-align:center; width:100px; background-color:#FFF; color:#CCC'><a href='?acao=excluir&idCliente=2' onclick="return verifica('Deseja Excluir este Cliente?')" '><img src='_img/excluir.png' height='30px' title='Excluir Cliente'/></a>
</li>
</ul>
</div>
<div style="clear:both; height:50px; width:100%;"> </div>
If you observe, the ul
listaTopo
, each li
, has a space between them. But the ul
listaRegistros
, with the same style
, is not giving this space between their li's
.
How to solve this?
Not related to your problem, but it seems redundant to use "listLi", no? could already use the own
li
as selector. For example<ul class="listaRegistros meuLi">
and in the CSS.meuli li {....
thus avoid repeating the class in the Lis (this would be used in several different Uls, otherwise it would be enough in the CSS.listaRegistros li, .listaTopo li {...}
– Bacco
yes. agent is learning.. I’ve changed here. But then, some idea of my mistake?
– Carlos Rocha
Apparently the spaces come from the line breaking between the Lis. Try (as a test only) to take the closing of the </li> and comment if something has changed. Leave only the <li> but remove the </li> and tell if the spaces are missing. If solved, a possible solution is to put the locks back, but leaning against the following <li>
– Bacco
each li is a column. Ma why did not give the error on the bottom ul?
– Carlos Rocha
Probably because of the other elements inside. Here are some examples of how to remove inline-block spaces. It’s in English, but the codes are easy to understand: https://css-tricks.com/fighting-the-space-between-inline-block-elements/ - Basically it’s changes in HTML formatting, not content. The problem is that tab and line breaks usually count as space.
– Bacco
Now, note: This list of records of yours should probably be a table, not a UL. Tabular data is formatted with
table
. UL is for simple lists.– Bacco
Check it out: It’s strange because the style of one is the same as the other, inside the first ul only has text (default: inline). At the bottom ul, li’s are being populated with data coming from the bank that is nothing more than text as well. Does it check? Only the last 3 options are links. I can’t understand why this happens!
– Carlos Rocha
Actually occurring is normal, the strange thing is not to appear in others (it may be a mere matter of them existing, but being aligned with something else) :) - anyway, try some of the changes I commented on the linked page, to see if this is the case or if there is any other problem.
– Bacco
except the /li solved. But will it be because it did not give the bottom ones? I do not find logic. hehehe. I even made margin: 0 and paddindg: 0 and nothing
– Carlos Rocha
One of the solutions is to return the </li>, but instead of putting at the end of the line, put next to the next. For example, in the second li you close the first:
</li><li>Segundo li
jumper</li><li>Terceiro li
and so it goes. There are other examples on that link, see which one looks best to format your code. We’re actually just changing the space. Another way out would be to change theinline-block
forfloat:left
. - but your case is typical fortable
, in fact, and notul
. The UL is not only semantically inadequate in this context will give you other headaches besides this.– Bacco
Yes. The idea of using ul, and then I ask you for advice, an opinion, is that this system will run on mobies too and I want to put each li in a row and each ul with a different color and then with tables does not work because they will stay in rows and columns. Some guidance in this regard?
– Carlos Rocha
If you want to put this solution as an answer, I’ll take it as an answer!
– Carlos Rocha
Without seeing the whole layout is really complicated I throb, maybe it’s easier to do everything with div then, or use some of those solutions to "kill" the spaces. Maybe the simplest thing is to put everything in one line:
<ul><li>1</li><li>2</li>...
– Bacco
even so. thank you very much!
– Carlos Rocha