Currently, I am attempting to create a responsive grid with 4 columns that expands to the entire width of the screen on desktop displays. However, when I introduce margins to space them out evenly, I encounter an issue where the last column either doesn't fill the remaining space or drops down to a new row due to the column widths.
CSS:
#servicesGrid
{
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
}
.service
{
width:24.75%;
height:45%;
background:#262626;
display:block;
float:left;
margin:1px;
}
#servicesGrid .service:nth-of-type(1)
{
width:100%;
}
#servicesGrid .service:nth-of-type(2)
{
margin-left:0;
}
#servicesGrid .service:nth-of-type(5)
{
margin-right:0;
}
HTML:
<div id="servicesGrid">
<div class="service"></div>
<div class="service"></div>
<div class="service"></div>
<div class="service"></div>
<div class="service"></div>
</div>
Check out the example on JSFiddle: https://jsfiddle.net/4bw4p3LL/.