0

I'm trying to make a cross browser CSS nav-bar for mobile and desktop using Jquery Mobile.

I don't want to use media queries for retina/non-retina devices, so I'm basically trying to use a single hi-res CSS icon/sprite on all devices. The following works nicely except on IE7+8.

HTML

<span class="hasIcon">
   <span class="someText"></span>
   <span class="someBackground"></span>
</span>

CSS

 .hasIcon {
   display: inline-block;
   position: static;
   height: 30px; width: 30px;
   background-color: none;
   background: url("http://www.franckreich.de/x/IMG/gen/6060dummy.png") no-repeat;
           background-size: 30px 30px;
        -o-background-size: 30px 30px;
   -webkit-background-size: 30px 30px;
      -moz-background-size: 30px 30px;
       -ms-background-size: 30px 30px;
   }

JsFiddle example here

Of course this breaks in IE7+8, as backgrond-size is not supported...

My question: Does anybody have an idea how I can achieve this effect on IE7+8?

Solutions, I don't want to use:

  • CSS Media Query for retina/non retina = miss out on good looks on desktop
  • put retina/non-retina icons in single sprite & position accordingly = works so-so & serving bigger file

Curious to see if anybody can help me out.

Thanks!

frequent
  • 27,643
  • 59
  • 181
  • 333

2 Answers2

0

You can use a filter: http://jsfiddle.net/thirtydot/QTT4N/3/

filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(
            src='http://www.franckreich.de/x/IMG/gen/6060dummy.png',
            sizingMethod='scale');

http://msdn.microsoft.com/en-us/library/ms532969(v=vs.85).aspx

thirtydot
  • 224,678
  • 48
  • 389
  • 349
0

Duplicate of IE 8: background-size fix. Short answer: Use IE Filter. http://www.pziecina.com/design/turorial_demos/resize_background.php

Community
  • 1
  • 1
Sheepy
  • 17,324
  • 4
  • 45
  • 69