HTMLの基本中の基本ですが、「改行マーク」は半角スペースと同等です。
HTML
1<style>
2.per40{display:inline-block;width:40%;}
3.per50{display:inline-block;width:50%;}
4.yellow{background-Color:yellow;}
5.lime{background-Color:lime;}
6.flex{display: -webkit-flex;display:flex;}
7</style>
8
9
10(1)1行表示
11<hr>
12<div class="per50 yellow">per50</div><div class="per50 lime">per50</div>
13<hr>
14(2)改行を回避
15<hr>
16<div class="per50 yellow">per50</div><!--
17--><div class="per50 lime">per50</div>
18<hr>
19(3)何もしない
20<hr>
21<div class="per50 yellow">per50</div>
22<div class="per50 lime">per50</div>
23<hr>
24(4)何もしない40%
25<hr>
26<div class="per40 yellow">per40</div>
27<div class="per40 lime">per40</div>
28<hr>
29(5)Flex
30<hr>
31<div class="flex">
32<div class="per50 yellow flex">per50</div>
33<div class="per50 lime flex">per50</div>
34</div>
35
36
(1)や(2)については理解されているようですが、なにもしなければ(3)のように
桁あふれになります。
これは(4)を見ればわかるように改行マークが半角スペースと同じように幅を
持っているからです。
つまり50%+50%+改行マークの幅>100%なのですからあふれるのは自明です。
この手の処理をどうしてもしたいなら(5)のようなflexなタグで囲んでください