I have a requirement that there are 4 fields in one line.
- drawers have a fixed width and height
- but the line width will change to fit the screen.
- the first box should be aligned with the left border of the row
- The last checkbox is right-aligned.
- Also, the space between any two cells must be equal.
Is there a clean CSS way to make this happen? Here jsfiddle code.
HTML:
<div class="row">
<div class ="col">
<div class="box"></div>
</div>
<div class ="col">
<div class="box"></div>
</div>
<div class ="col">
<div class="box"></div>
</div>
<div class ="col">
<div class="box"></div>
</div>
</div>
CSS
.row {
display: table;
border: 1px solid green;
width: 400px;
padding: 5px;
}
.row:before, .row:after {
content: "";
}
.row:after {
clear: both;
}
.col {
float: left;
width: 25%;
}
.box {
border: 1px solid #DDD;
width: 80px;
height: 80px;
margin: 0 auto;
}
.col:first-child .box {
margin-left: 0;
}
.col:last-child .box {
margin-right: 0;
}
source
share