Author Topic: TD-width  (Read 959 times)

Offline Sinzygy

  • Level 28
  • **
  • Posts: 420
  • Reputation: +11/-0
    • View Profile
TD-width
« on: June 15, 2007, 02:05:16 AM »
I don't really know where this belongs to, but I figured this is the area with the most similarities. Maybe open an explicit website-design section?

Anyways:

How reliable are percentage-amounts in td-width specifications?
What I basicly need to know is: do all browsers support percentage-widths in a td-element and how accurate are they displayed? I mean, do any browsers add additional values to suit their display-system?
I want to create bar-like images without the use of gdLibrary and I figured I'd try it by using different colored td-elements

Code: [Select]
<table width="100%" class="bg" cellpadding="1">
    <tr>
        <td class="bright" width="85%">85%</td>
        <td class="dark" width="15%"></td>
    </tr>
</table>

Offline dvd871

  • Level 21
  • *
  • Posts: 238
  • Reputation: +7/-0
    • View Profile
    • Dominion Siege
Re: TD-width
« Reply #1 on: June 15, 2007, 09:59:10 AM »
I do this in one of my games already and its work very nice. I've never had any complaints from players about it not working.  Here's a sample function that does a hit points bar:

Code: [Select]
function hpbar() {
    global $session;
    $hpmax = $session['user']['maxhitpoints'];
    $curhp = $session['user']['hitpoints'];
    $pct = round(($curhp/$hpmax)*100);
    $nonpct = 100 - $pct;
    $u = "<font face=\"verdana\" size=1>" . number_format($curhp) . "/" . number_format($hpmax) . "<br><table style=\"border: solid 1px #000000\" cellspacing=\"0\" width=\"70\" height=\"6\">";
    if ($pct > 0){
        $u = $u . "<tr><td width=\"".$pct."%\" bgcolor=\"green\"></td>";
        }
    if ($nonpct > 0){
        $u = $u . "<td width=\"".$nonpct."%\" bgcolor=\"white\"></td></tr></table>";
    }else {
        $u = $u . "</tr></table>";
    }
return($u);
}

You will need to alter the code to suit your needs but it should give you an idea of how it works.

Offline Sinzygy

  • Level 28
  • **
  • Posts: 420
  • Reputation: +11/-0
    • View Profile
Re: TD-width
« Reply #2 on: June 15, 2007, 11:01:21 AM »
nice, thanks a lot :)

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal