Is there a way to achieve 5 floating divs on one row with a 20px margin-right between each, except for the last-child?
This is the desired structure:
<div class="f-item pull-left">1</div>
<div class="f-item pull-left">2</div>
<div class="f-item pull-left">3</div>
<div class="f-item pull-left">4</div>
<div class="f-item pull-left">5</div>
I attempted the following CSS code, but it didn't work as expected (the "reset" on last-child seemed to be ignored):
.f-item {
margin-right: 20px;
width: 20%;
&:last-child {
margin-right: 0;
}
}
You can view an example in this Fiddle.
.f-group {
width: 100%;
}
.f-item {
margin-right: 20px;
width: 20%;
background-color: green;
text-align: center;
color: white;
}
.f-item:last-child {
margin-right: 0;
}
.col-sm-12 {
background-color: red;
padding: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.css" rel="stylesheet"/>
<div class="col-sm-12">
<div class="f-group">
<div class="f-item pull-left">
1
</div>
<div class="f-item pull-left">
2
</div>
<div class="f-item pull-left">
3
</div>
<div class="f-item pull-left">
4
</div>
<div class="f-item pull-left">
5
</div>
<div class="clearfix"></div>
</div>
<div class="col-sm-12">