Like in case of tables
TD WIDTH 25 TD WIDTH 75
this is what I want to achieve with DIV/SPAN. All I have:
<span style="background-color: green; width: 25%; display: inline-block;">1</span>
<span style="background-color: yellow; width: 75%; display: inline-block;">2</span><br />
<span style="background-color: green; width: 25%; display: inline-block;">a</span>
<span style="background-color: yellow; width: 75%; display: inline-block;">b</span><br />
but then puts span to new line. It works with fix (px) sizes.
use float
<span style="background-color: green; width: 25%; float:left;">1</span>
<span style="background-color: yellow; width: 75%; float:right;">2</span><br />
<span style="background-color: green; width: 25%; float:left;">a</span>
<span style="background-color: yellow; width: 75%; float:right;">b</span><br />
The problem is with the whitespace between the two spans.
<span style="display:inline:block; width:25%">..</span>
<span style="display:inline:block; width:75%">..</span>
These have a space between them, so the whole thing won't fit in 100%; it's 100% plus the width of a space wide.
If you remove the newline between the two spans, it will work.
<span style="display:inline:block; width:25%">..</span><span etc...>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With