0

What I need

Protein      8g   25%
Fiber        1g    3%
<a><span style="float:right">8g &nbsp; &nbsp; 25%</span> Protein</span></a>
<a><span style="float:right">1g &nbsp; &nbsp; 3%</span> Fiber</span></a>

This code doesn't work when the percent values differ. It makes all the gram values ragged. Can you help me with this?

3
Contributors
7
Replies
8
Views
8 Years
Discussion Span
Last Post by MidiMagic
0

I need this

_1g____1%
_2g___10%
34g__100%

where the "_" characters are blank spaces.

0

even better

___1g_____1%
___2g____10%
__30g___100%

instead of

___1g____1%
_20g____20%
___5g____5%

0

I can write sprintf commands in Ruby.. sprintf "Protein %3.1fg%4.0f%%", @grams, @daily_value Unfortunately, html doesn't pick up the spacing outside a <pre> element, and my css doesn't like what I'm trying to do with the <pre> element.

0

you mean like this? Protein <table><tr><td>2 g</td><td>5%</td></tr></table>

0

Yes. Then apply a style to the td tag that aligns the text to the right.

<style type="text/css">
.rt {text-align: right;}
</style>
.....
<table>
  <tr>
    <td>Protein</td>
    <td class="rt">8g</td>
    <td class="rt">25%</td>
  </tr>
  <tr>
    <td>Fiber</td>
    <td class="rt">1g</td>
    <td class="rt">3%</td>
  </tr>
</table>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.