Thursday, April 12, 2012

span with percentage width

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.



Answer:


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 />

No comments:

Post a Comment