How do I get 5 (20% equal) floating divs on one row with 20px margin-right between in each except the last-child?
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>
Tried with the following, which breaks the row (and "reset" on last-child seems to be ignored):
.f-item {
margin-right: 20px;
width: 20%;
&:last-child {
margin-right: 0;
}
}
Fiddle with example.
.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">