CSS Ruler problem positioning multiple <div> containers

Posted on 2007-10-20
Last Modified: 2008-01-09
This is a CSS issue as another guy was wanting me to build a dynamic ruler that he can add peoples scores to the array and have them move up & down the ruler. Well When you see this code in action youll see that it does what he wants BUT when we get to scores round to the same number to display on it is putting them on top of each other. See what you guys think will straighten it out. We can just display them to the right of each other. Thanks

      $scores = array(array('name'  => 'bob',      
                                      'score' => '58.0'
                              array('name'  => 'jill',
                                      'score' => '52.3'
                              array('name'  => 'jack',
                                      'score' => '48.1'
                              array('name'  => 'tom',
                                      'score' => '44.2'
                              array('name'  => 'mary',
                                      'score' => '35.9'
                              array('name'  => 'rick',
                                      'score' => '35.5'
                              array('name'  => 'don',
                                      'score' => '27.8'
                              array('name'  => 'moe',
                                      'score' => '23.3'
      $high_score = (int) 0;
      $i = count($scores);
      $j = 0;
      for($k = 0; $k < $i; $k++) {
            if($scores[$j]['score'] > $high_score) {
                  $high_score = (int) $scores[$j]['score'];
      $rulerTop = substr($high_score, 0, 1);
      $rulerTop .='0';
      for($l = $rulerTop; $l >= 20; $l--) {

                  if(substr($l, 1, 2) == '0') {
                        echo('<td style="border-right: thin solid blue"><b>'."$l".'</b>&nbsp;</td>');
                  } else {
                        if($l & 1) {
                              echo('<td valign="middle" style="text-align:right; border-right: thin solid blue"></td>');
                        } else {
                              echo('<td valign="middle" style="text-align:right; border-right: thin solid blue">--</td>');

            $n = '';
            for($m = 0; $m < $i; $m++) {
                  if(round($scores[$m]['score']) == $l) {
                        $n .= '<td style="padding-top: 0px; padding-left: 0px; padding-right: 0px; padding-bottom: 0px;"><div id="'."$m".'outer" name="'."$m".'outer" style="position: relative; z-index: '."$m".';"><div id="'."$m".'inner" name="'."$m".'inner" style="position: absolute; bottom: -10px; z-index: '."$m".';">&nbsp;';
                        $n .= $scores[$m]['score'];
                        $n .= '&nbsp;';
                        $n .= ucwords($scores[$m]['name']);
                        $n .= '</div></div</td>';

You can see close to the bottom here where I have all the css trying to control the output form. He said it looked fine in firefox as Im using Safari and that he had a slight adjustment for IE so ill just use the PHP commands to check the browser and adjust the offset.
Question by:gemdeals395
    LVL 5

    Accepted Solution

    You'll have to work out in the php if two scores are going to graphically overlap and adjust before sending the html. Good luck...
    LVL 7

    Author Comment

    It was worked out in the thml, thanks
    LVL 5

    Expert Comment

    lol, 2000 points for one non-committal sentence isn't bad eh?

    Thanks gemdeals

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Most web designers often experience crossbrowser issues during interface design / development.  On common problem is with Internet Explorer due to its rendering discrepancies between previous versions.  Here are some techniques I use to help avoid c…
    CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
    In this tutorial viewers will learn how add a full-size background image to a webpage using CSS3. Create a new HTML document with an internal stylesheet.: In CSS, define the html element to have a background image. Use a high resolution image.: In t…
    In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at Browse or search based on font properties or name to find a suitable font for…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now