Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. CSS Image Sprites in IE7

CSS Image Sprites in IE7

Scheduled Pinned Locked Moved Web Development
javascriptcsshelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hxhl95
    wrote on last edited by
    #1

    Hi everyone, I've got a few icons I'm using sprites for, however they seem to work in every single browser except IE7. My code's very simple:

    <div style="display:inline;margin:0 10px">
    <a href="javascript:window.print()" title="Print">
    Print Page <div class="useicon" style="background-position:0px 0px"></div>
    </a>
    </div>

    My useicon class:

    div.useicon {
    display:inline;
    height:16px;
    width:16px;
    background:url('../img/icons.gif') no-repeat 0px 0px;
    padding:0 8px
    }

    Now the problem apparently is the display:inline part of that - the sprites just don't show up as long as that div is inline (if I remove display:inline the sprites show up but the thing is I want everything on the same line). Already tried using span instead of div, unfortunately it appears that as long as the object is inline the sprites won't show up. Any suggestions? The padding: 0 8px is there to keep the width at 16px, because some browsers completely collapse the div because it's empty even though I've specified width:16px. Thanks in advance :)

    G J 2 Replies Last reply
    0
    • H hxhl95

      Hi everyone, I've got a few icons I'm using sprites for, however they seem to work in every single browser except IE7. My code's very simple:

      <div style="display:inline;margin:0 10px">
      <a href="javascript:window.print()" title="Print">
      Print Page <div class="useicon" style="background-position:0px 0px"></div>
      </a>
      </div>

      My useicon class:

      div.useicon {
      display:inline;
      height:16px;
      width:16px;
      background:url('../img/icons.gif') no-repeat 0px 0px;
      padding:0 8px
      }

      Now the problem apparently is the display:inline part of that - the sprites just don't show up as long as that div is inline (if I remove display:inline the sprites show up but the thing is I want everything on the same line). Already tried using span instead of div, unfortunately it appears that as long as the object is inline the sprites won't show up. Any suggestions? The padding: 0 8px is there to keep the width at 16px, because some browsers completely collapse the div because it's empty even though I've specified width:16px. Thanks in advance :)

      G Offline
      G Offline
      Gerben Jongerius
      wrote on last edited by
      #2

      You might need to add a space to your div containing the sprite, inline rendering should always cause the height attribute to be ignored. You will also need to add the style a {text-decoration: none;} to avoid an ugly line in your empty div.

      H 1 Reply Last reply
      0
      • G Gerben Jongerius

        You might need to add a space to your div containing the sprite, inline rendering should always cause the height attribute to be ignored. You will also need to add the style a {text-decoration: none;} to avoid an ugly line in your empty div.

        H Offline
        H Offline
        hxhl95
        wrote on last edited by
        #3

        Thanks! I can't believe I forgot to try that. It's working fine now.

        1 Reply Last reply
        0
        • H hxhl95

          Hi everyone, I've got a few icons I'm using sprites for, however they seem to work in every single browser except IE7. My code's very simple:

          <div style="display:inline;margin:0 10px">
          <a href="javascript:window.print()" title="Print">
          Print Page <div class="useicon" style="background-position:0px 0px"></div>
          </a>
          </div>

          My useicon class:

          div.useicon {
          display:inline;
          height:16px;
          width:16px;
          background:url('../img/icons.gif') no-repeat 0px 0px;
          padding:0 8px
          }

          Now the problem apparently is the display:inline part of that - the sprites just don't show up as long as that div is inline (if I remove display:inline the sprites show up but the thing is I want everything on the same line). Already tried using span instead of div, unfortunately it appears that as long as the object is inline the sprites won't show up. Any suggestions? The padding: 0 8px is there to keep the width at 16px, because some browsers completely collapse the div because it's empty even though I've specified width:16px. Thanks in advance :)

          J Offline
          J Offline
          jahangir_ahmad
          wrote on last edited by
          #4

          Hi dear you can let div#useicon stay block level but you must change a to block level and then float the div#useicon for gain width and height. and that work in all IE versions. here the css code:

          a
          {
          display:block;
          width:16px;
          height:16px;
          overflow:hidden;
          }
          div#useicon
          {
          width:16px;
          height:16px;
          float:left;
          }

          I used overflow for get arount collapse height because of floating div#useicon.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups