I have a container on my page with the specified width; this means that you can center all the buttons on the page.
I use margin-righton buttons, but I can’t fill the container with buttons so that they go to the edge with the container, otherwise they are reconfigured, and the grid becomes 3x4 instead of the desired 4x3.
So, how do I get rid of the margin at the end of the buttons? I can not use the selector :last-child.
<div id="container">
<div id="months">
<div class="month-button jan" data-month="January"></div>
<div class="month-button feb" data-month="February"></div>
<div class="month-button mar" data-month="March"></div>
<div class="month-button apr" data-month="April"></div>
<div class="month-button may" data-month="May"></div>
<div class="month-button jun" data-month="June"></div>
<div class="month-button jul" data-month="July"></div>
<div class="month-button aug" data-month="August"></div>
<div class="month-button sep" data-month="September"></div>
<div class="month-button oct" data-month="October"></div>
<div class="month-button nov" data-month="November"></div>
<div class="month-button dec" data-month="December"></div>
</div>
</div>
CSS:
#container {
width: 900px;
margin: 10px auto;
}
#months {
margin: 10px 5px 21px;
float: left;
}
.month-button {
width: 115px;
height: 26px;
background: url("/__resources/images/months.png");
cursor: pointer;
float: left;
margin: 8px 87px 0px 0px;
}

source
share