2
I have a problem with my css. I was working on a style to format some buttons. Everything went well. However, my buttons are with an extra margin showing up. That is, I have not set margin on my buttons, but they are showing in margin.
Example:
.container .item{
background-color: lightgreen;
display:inline-block;
margin:0;
padding:10px;
}
<div class="container">
<button class="item">Item</button>
<button class="item">Item</button>
<button class="item">Item</button>
</div>
Notice that I set the button to have margin:0, but the same is on the margin.
I realized that the problem happens because of inline-block, because when I change to block with float:left the problem is solved. See:
.container .item {
float: left;
background-color: lightgreen;
margin:0;
display:block;
}
<div class="container">
<button class="item">Item</button>
<button class="item">Item</button>
<button class="item">Item</button>
</div>
However float:left in that case it is not desirable as, for example, I usually use text-align:right to change the button alignments, and this does not work with float:left.
Is there any way to remove these extra margins that are appearing without taking the inline-block of my buttons?
I did not understand why they gave -1. The answer is not wrong.
– Wallace Maxters