开发者

Inline CSS required to display image map in Firefox?

I've included an image map using CSS (as described in this rather old 2004 article in A List Apart) in an externally-hosted a Facebook iframe page. I'm using an image map with images for a:link/a:hover, with the CSS included in an external stylesheet. The page displays correctly in Safari and Chrome, but not in Firefox 3.6 on Mac OS X.

If I switch back to inline styles, the page displays properly in Firefox.

Here's the code with the styles applied inline:

<style type="text/css">
 #home-page-nav {
    width: 512px; height: 139px;
    background: url(http://mysite.com/imagemap.jpg);
    margin: 10px auto; padding: 0;
    position: relative;}
  #home-page-nav li {
    margin: 0; padding: 0; list-style: none;
    position: absolute; top: 0;}
  #home-page-nav li, #home-page-nav a {
    height: 141px; display: block;}

  #blog-icon {left: 0; width: 127px;}
  #links-icon {left: 128px; width: 128px;}
  #twitter-icon {left: 256px; width: 128px;}
  #flickr-icon {left: 384px; width: 128px;}

  #blog-icon a:hover {
    background: transparent url(http://mysite.com/imagemap.jpg)
    0 -139px no-repeat;}
  #links-icon a:hover {
    background: transparent url(http://mysite.com/imagemap.jpg)
    -128px -139px no-repeat;}
  #twitter-icon a:hover {
    background: transparent url(http://mysite.com/imagemap.jpg)
    -256px -139px no-repeat;}
  #flickr-icon a:hover {
    background: transparen开发者_运维技巧t url(http://mysite.com/imagemap.jpg)
    -384px -139px no-repeat;}  
</style>

<ul id="home-page-nav">
    <li id="blog-icon"><a href="http://donaldjenkins.net/"></a></li>
    <li id="links-icon"><a href="http://links.donaldjenkins.net/"></a></li>
    <li id="twitter-icon"><a href="http://twitter.com/donaldjenkins"></a></li>
    <li id="flickr-icon"><a href="http://flickr.com/photos/astorg"></a></li>
</ul>

Any suggestions as to solving this welcome.

UPDATE: The solution was found thanks to Neil below. Just in case anyone else has the same issue, here's how to fix it. The solution is to update the configuration of the web server hosting the CSS file. Some Apache and iPlanet web servers are associating files having a .CSS with an incorrect MIME-type such as "text/plain" or "application/x-pointplus". In some cases, Netscape 7.x and Mozilla ignore the CSS file because of its wrong MIME type and use a default style sheet that causes the layout to be different from what was intended by the web developer. See this page on the Mozilla Development Network for more details.

The simplest way to solve it is by including the following line in your .htaccess file:

AddType text/css .css


As a security feature, external stylesheets must be served with the text/css MIME type, otherwise they will be ignored by Firefox.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜