We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    I’m hoping this is an easy question for a CSS guru (which I’m definitely not).

    I’m trying to adapt a fundraising thermometer image to work with MODx. It’s a WordPress plugin that does everything in CSS. It’s simple and, unlike most thermometers, it has blue ink which the person I’m doing the site for is determined to have.

    I’ve got it working perfectly in FF, but in IE7, the mercury in the thermometer is shifted up about 10% of the way to the top. It reads 10% higher than it should, and there’s a gap between the bulb and the mercury. I’ve tried everything I can think of but nothing has worked.

    I’ve boiled it down to a minimal form to get it working.

    Snippet:

    <?php
    $src = 'http://localhost/bobsguides/assets/snippets/thermox/style.css';
    $modx->regClientCSS($src);
    
    function roundnum ($num, $nearest)
    {
       $ret = 0;
       $mod = $num % $nearest;
       if ($mod >= 0)
         $ret = ( $mod > ( $nearest / 2)) ? $num + ( $nearest - $mod) : $num - $mod;
        else
         $ret = ( $mod > (-$nearest / 2)) ? $num - $mod : $num + ( -$nearest - $mod);
        return $ret;
    }
    
    echo "<div class='ourprogress'>\n";
        echo "<div class='ourprogressgraphics'>\n";
        $current = 3000;
        $max = 10000;
    
        $percent = round(($current/$max)*100);
        $percent = str_pad(roundnum($percent, 10), 2, "0", STR_PAD_LEFT);
    
        echo "<div class='ourprogressmercury percent30'>\n";
        echo "<div class='ourprogressmercurytop'></div>\n";
        echo "</div>\n";
        echo "</div>\n";
        echo "<div class='ourprogressnumbers'>\n";
        for ( $counter = $max; $counter >= 0; $counter=$counter-($max/10)) {
            echo "<div class='progressvalue'>".$counter."</div>\n";
    
        }
        echo "</div>\n";
        echo "</div>\n";
    
    ?>


    CSS:

    .ourprogress {
    	width: 200px;
    	height: 500px;
    	background-image: url(progress.jpg);
    }
    
    .ourprogressgraphics {
    	width: 13px;
    	padding: 48px 0px 0px 42px;
    	float: left;
    }
    .ourprogressmercury {
    	background-image: url(mercury.jpg);
    	background-repeat: repeat-y;
    }
    .ourprogressmercurytop {
    	background-image: url(mercury-top.jpg);
    	width: 13px;
    	height: 7px;
    }
    .ourprogressnumbers {
    	float: right;
    	margin: 25px 10px 0px 0px;
    	font-size: 10px;
    	color: #123456;
    	text-align: right;
    	width: 100px;
    
    }
    .progressvalue {
    	border-top: solid 1px #cccccc;
    	margin: 25px 0px 0px 0px;
    }
    
    .percent00 {margin-top: 395px; height: 0px;}
    .percent10 {margin-top: 360px; height: 40px;}
    .percent20 {margin-top: 320px; height: 80px;}
    .percent30 {margin-top: 280px; height: 120px;}
    .percent40 {margin-top: 240px; height: 160px;}
    .percent50 {margin-top: 200px; height: 200px;}
    .percent60 {margin-top: 160px; height: 240px;}
    .percent70 {margin-top: 120px; height: 280px;}
    .percent80 {margin-top: 80px; height: 320px;}
    .percent90 {margin-top: 40px; height: 360px;}
    .percent100 {margin-top: 0px; height: 400px;}


    I’ve attached the images (and the CSS and PHP files slightly modified for my local install) in the zip file. I’d like to get this working. I think it might be a useful snippet and all the other thermometer examples I’ve looked at would be much more work to snippetize.
      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 25663 MODX Staff
      • 12,272 Posts
      Do you have a link to this live? I bet anything a hack to the CSS would fix it right up using a Conditional Comment. IE tends to disagree on things with other browsers when floats and margins get involved. You might also try adding an IE-specific CSS declaration that will break validation but may fix it too, to all the thermometer elements. Wrap this in a CC if it works and you don’t want it to mess up validation:

      .ourprogressgraphics, .ourprogressgraphics * { zoom: 1 }
      
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 3749
        • 24,544 Posts
        The zoom fix didn’t seem to work, but maybe I misapplied it.

        @ryan: sent you more info by PM.

        Any other thoughts welcome.
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 3707
          • 241 Posts
          Try adding position:absolute; to the mercury class
          .ourprogressmercury {
          	position: absolute;
          	background-image: url(mercury.jpg);
          	background-repeat: repeat-y;
          }
            • 3749
            • 24,544 Posts
            Quote from: bob1000 at Jan 15, 2009, 04:47 PM

            Try adding position:absolute; to the mercury class
            .ourprogressmercury {
            	position: absolute;
            	background-image: url(mercury.jpg);
            	background-repeat: repeat-y;
            }


            That seems to have fixed it. Thanks a million -- it was driving me crazy. grin

            Can you explain why IE7 needs that and not the other browsers?

              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 29525
              • 388 Posts
              Browsers do have different default padding and margins for various elements (among other things).  It’s possible you bumped up against differing defaults for some particular element. 

              I always start my pages with a css reset file to set all those padding & margins to zero.  Once set to zero, the style sheet isn’t adding to some default that’s not same across browsers.  If the reset and style doesn’t fix it, then I resort to conditional style sheets.

              BTW IE6 and IE7 have different defaults as well. . .
                www.terrybarthdesign.com
                • 3749
                • 24,544 Posts
                Quote from: Terry at Jan 15, 2009, 06:09 PM

                Browsers do have different default padding and margins for various elements (among other things). It’s possible you bumped up against differing defaults for some particular element.

                I always start my pages with a css reset file to set all those padding & margins to zero. Once set to zero, the style sheet isn’t adding to some default that’s not same across browsers. If the reset and style doesn’t fix it, then I resort to conditional style sheets.

                BTW IE6 and IE7 have different defaults as well. . .

                Earlier, I tried setting the margin and padding for every element to 0, but it had no effect.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 3707
                  • 241 Posts
                  Quote from: BobRay at Jan 15, 2009, 05:19 PM

                  Can you explain why IE7 needs that and not the other browsers?
                  I don’t know the technical reason behind it but ie7 doesn’t seem to recognise the 48px padding at the top of the .processgraphics div when it’s following the normal document flow.

                  If you remove the position: absolute then add 48px to the the margin-top value for each of the percent classes, it will work correctly in ie7 (but break in other browsers).

                  By removing the div from the normal flow with absolute positioning, ie7 (and other browsers) now respects the top padding.

                  Another way to fix it would be to edit the background image (progress.jpg) so that there’s no white space at the top of the image. Then you wouldn’t need the top padding.
                    • 25551 ☆ A M B ☆
                    • 1,231 Posts
                    At the top of your css file have you tried using * {padding:0px; margin:0px} this should reset all padding and margins in each browser before you start using new classes and ids.
                      Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                      AugmentBLU - MODX Partner

                      BLUcart - MODX Revolution E-Commerce & Shopping Cart
                      • 3749
                      • 24,544 Posts
                      Quote from: rossco at Jan 16, 2009, 06:05 AM

                      At the top of your css file have you tried using * {padding:0px; margin:0px} this should reset all padding and margins in each browser before you start using new classes and ids.

                      I didn’t try that, but I did set padding and margin to 0 for every element. Based on Bob1000’s explanation, I don’t think less padding or margin would have solved it.


                      I did find this in my search for anwsers: http://www.chigarden.com/2007/10/tutorial-making-the-ie-voodoo-doll/ wink
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting