All of the widths and margins come out to a total of 99.96%, so it should fit just fine in the 100%. I understand that borders add width, so I've done box-sizing: border-box;
but that doesn't seem to fix it. If I float: left
then it works okay in Chrome, but I feel like that's a crappy workaround anyway and doesn't actually fix the problem.
Why doesn't it all fit on one line?
HTML
<div id="container">
<a href="#">
1
</a>
<a href="#">
2
</a>
<a href="#">
3
</a>
<a href="#">
4
</a>
</div>
CSS
body {
border: 1px solid black;
background-color: #BCCDDC;
margin: 5% 25%
}
#container a {
font-family: 'Open Sans', sans-serif;
text-align: center;
box-sizing: border-box;
-webkit-box-sizing: border-box;
border: 2px solid #fff;
display: inline-block;
width: 15%;
margin: 0 6.66%;
padding: 20px 0;
}
#container a:first-of-type {
margin-left: 0 !important;;
}
#container a:last-of-type {
margin-right: 0 !important;
}