I want four divs to appear on the same line. I can make three of them do it but the other won't unless I make the total width that the four divs take up less than 100%.
This shouldn't happen though, right? They should be able to, in total, take up 100% of the page width if there is nothing else 'in the way'? Below is a snippet with my code of what I mean.
* {
margin: 0;
padding: 0;
}
html,
body {
overflow: hidden;
font-size: 10px;
}
.wrapper {
position: absolute;
bottom: 0;
width: 100%;
margin-bottom: 0.5%;
margin-left: 0.5%;
margin-right: 0.5%;
}
.inner {
display: inline-block;
vertical-align: top;
width: 25%;
}
.half {
width: 12.5%;
}
<div class="wrapper">
<div class="inner" style="background-color: red;">Div 1</div>
<div class="inner" style="background-color: blue;">Div 2</div>
<div class="inner" style="background-color: green;">Div 3</div>
<div class="inner">
<div class="inner half" style="background-color: purple;">Div 4 - First Half</div>
<div class="inner half" style="background-color: Teal;">Div 4 - Second Half</div>
</div>
</div>
I haven't checked to see if aligning the divs on the same line using float: left
will make a difference to the problem as I need to use display: inline-block
for aligning other thighs in the divs in my actual code.
So does any one know how to get the last one to appear on the same line?