html - How to make two divs of a total of 100% width fit in the screen -
here a fiddle
i want 2 divs side side occupying width of window. use display:inline-block
on them behave horizontally.
<div id="left" class="horizontal">hello</div> <div id="right" class="horizontal">world</div>
the problem when set width equal 100% (left @ 20% , right @ 80%) take larger screen, , div on right gets pushed under other one.
i around setting width smaller 100% (19% , 79%) has minor problems later on, putting unwanted spaces not want it.
what missing make divs along horizontally while using 100% of screen?
i have seen tricks listed here, in this question... , of them ugly still prefer using less 100% width.
* { padding:0; margin:0; border:0; border-spacing:0; box-sizing: border-box; -moz-box-sizing: border-box; } html { height:100%; } body { height:100%; } #left { background-color: red; width:20%; height:100%; } #right { background-color: green; width:80%; height:100%; } .horizontal { display: inline-block; }
if don't need use inline-block
recommend use block
instead. block
default value display
of div
, not have explicitly set it. set float
left
, won't have "fight space between inline block elements".
example:
.horizontal { float: left; }
Comments
Post a Comment