2011-06-01 26 views
1

css适用于firefox,但不适用于Chrome或Chrome。如何修复的CSS,至少IE浏览器像Firefox一样工作。html -css check for chrome,即&firefox

火狐:

enter image description here

IE:

enter image description here

的图像是在背景中,以及,但应该是透明的。

铬:

enter image description here

的HTML

<center><div id="slideshowContentArea" style="display:none; width:500px; height:300px"> 
    <div class='nav'><a id='prev' href='#'>Prev</a>&nbsp&nbsp<a id='next' href='#'>Next</a></div> 
    <div id="slideshow" class="pics" style="position: relative; overflow-x: hidden; overflow-y: hidden; height:250px; width:395px">&nbsp;</div> 
</div></center> 

     $('#slideshow').cycle(
      { fx: 'fade', timeout: 3000, speed: 500, 
       pager: '#slideshow', before: setBGBefore, prev:'#prev',next:'#next',after:onAfter 
      } 
      ); 
     function setBGBefore() { 
     $(this).css({ 'background-image': 'url(' + $(this).find('img').attr('src') + ')', 
     'background-position': 'center top', 'background-color': 'transparent' }); 
     $(".welcomeBox div").html($(this).find('span').html()); 
     } 
+2

那么,修复CSS我必须看到CSS。你可以发布吗? – Blender 2011-06-01 16:09:22

+0

@Blender:我很抱歉,css被嵌入在setbgbefore函数里 – 2011-06-01 16:16:19

+0

这不是整个CSS,我很确定。 – Blender 2011-06-01 16:17:55

回答

1

jQuery的可以告诉你使用的浏览器:

http://api.jquery.com/jQuery.browser/

更新。 问题标题是“检查铬,即& firefox”这就是我已经回答。如果他希望实施更优雅的解决方案,则由OP负责。

+4

正确的答案不是嗅探浏览器,而是找到一个合适的解决方案,在所有浏览器中产生相同的输出。 – 2011-06-01 16:16:06

+0

跨浏览器的边距和填充工作的方式不同 - 尤其是对于旧版本 - 快速浏览器嗅探以纠正非常小的问题并不是一个坏方法。 – Mikaveli 2011-06-01 16:17:58

+0

使用CSS重置可能有助于解决Mikaveli提到的一些填充和边距问题。 http://developer.yahoo.com/yui/reset/ – jszpila 2011-06-01 16:44:12