We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23299
    • 1,161 Posts
    I have a header with a graphic. On top of the graphic I have a h1 headline. I am indenting the text big time and am using a graphic as a background for the h1. I also have a different graphic for the hover state.

    The hover effect works if the page has not been displayed before. But once it has the hover effect stops working: the pointer icon does not show either.

    I have used this technique with static XHTML and CSS pages with no problems.

    Is there something I should be changing? A cache setting perhaps? Something with the CSS?

    Thanks,

    Max
      • 29703
      • 217 Posts
      Have you got a live example, or a sample of your CSS?
        • 23299
        • 1,161 Posts
        Yes, its www.seattlecruiserheads.com
        You just commented on the site over in the sites area...

        max
          • 29703
          • 217 Posts
          Hmm, you seem to have approached this particularly awkwardly. I would recommend reevaluating your code.

          Firstly, I’d move away from the absolute positioning of html tags. I would look at something like this:

          h1 a{
          display:block;
          height:77px;
          width:385px;
          background: url(../images/logo_off.gif);
          text-indent:-9000px;
          overflow: hidden;
          margin:8px 0 0 122px;
          }
          
          h1 a:hover {
          background-image: url(../images/logo_on.gif);
          }


          That literally is all your unnecessary h1 css condensed and the positioning fixed.

          This is your code for the h1 tags at the moment:

          h1 {margin:0;
          position:absolute; /*move away from absolute positioning*/
          z-index:3; /*""*/
          top:-8px;/*""*/
          left:122px;/*""*/
          text-indent:-9000px;/*common fix - doesnt work in IE5 and has accessibility issues*/
          width:385px;
          height:77px;
          background-image: url(../images/logo_off.gif);
          background-repeat: no-repeat; /*unneccessary - you've already specified width and height*/
           border:none;} /*there wouldn't be a border anyway*/
          
          h1 a:link {display:block; /*this should be declared in the previous statement*/
          height:77px; /*already declared*/
          background-image: url(../images/logo_off.gif); /*already declared*/
          background-repeat: no-repeat; /*unneccessary and already declared*/
          border:none;} /*there wouldn't be a border anyway*/
          
          h1 a:visited {
           border:none; /*there wouldn't be a border anyway*/
          }
          
          h1 a:hover {
          display:block; /*already declared*/
          height:77px; /*already declared*/
          background-image: url(../images/logo_on.gif);
           border:none;} /*already declared*/
          
          h1 a:active{display:block; /*already declared*/
          height:77px; /*already declared*/
          background-image: url(../images/logo_off.gif); 
          background-repeat: no-repeat; /*unneccessary - you've already specified width and height*/
          border:none;}/*there wouldn't be a border anyway*/


          Although this would clean up your code and make it more logical, it doesn’t guarantee it will fix your problem - though I’m pretty sure it’s your declaration of display types in the link states that are your problem.
            • 23299
            • 1,161 Posts
            Thanks,

            The graphic for the headline is above the actual photo.

            The reason I had the borer=none was that IE6 was showing a bottom border? Adding this seemed to take care of the issue.

            I will look at that code and see how it fits in etc.

            Max
              • 29703
              • 217 Posts
              The graphic for the headline is a background image too.

              If you have a DIV with a background image, a DIV inside it with another background image would appear on top.

              I wouldn’t use absolute positioning and Z-Index for this kind of layering - things can get messy smiley

              To get rid of unwanted borders, margins and padding, at the start of your CSS declare this:

              * {
              border:none;
              padding:none;
              margin:0
              }
              


              This avoids 99% of my cross-browser compatibility issues that I usually face.
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Actually, I’m doing exactly this on one site... a div with a background that is set to a random image using a snippet in a bit of a <style> tag in the template head, with another div with an image with a transparent rounded center over the random background image, to form a nice frame. The client can just upload images to the assets/images/top folder and they are automatically added to the random choices.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 23299
                  • 1,161 Posts
                  Thanks for that code. I am not sure what I was thinking. I think I tried too many solutions that got out of hand. Not thinking...That simpler CSS is much better.

                  I did get the bottom border in IE6 again. I will try switching the border:none to the body instead of the H1.

                  The one thing I notice is the h1 image does not quite line up in IE6 but does in the better browsers. In IE6 you can see the outline of the graphic just a bit if you look closely. I tried changing the margins just a bit but the problem is still there. You have to be really looking for it as it looks like the IE6 positioning is off by a pixel or two.

                  I am very pleased to be tracking this issue down now. I sort of stopped addressing it a while back ( that’s the problem of working on a project intermittently.)
                    • 23299
                    • 1,161 Posts
                    hmmm,

                    Switching the border:none to the body instead of the h1 made the bottom border show in IE6 again. The two issues might be related?

                    Gotta run out the door and look at this later...
                      • 29703
                      • 217 Posts
                      Quote from: Photowebmax at Mar 13, 2008, 03:00 PM

                      hmmm,

                      Switching the border:none to the body instead of the h1 made the bottom border show in IE6 again. The two issues might be related?

                      Gotta run out the door and look at this later...

                      * {
                      border:none;
                      padding:none;
                      margin:0
                      }


                      The asterix applys the statement to all elements.