2012-05-04 130 views
0

我在頁面中嵌入了媒體播放器。CSS高度在Firefox中不起作用

而且我已經檢測到瀏覽器解決方案來調整播放器的寬度和高度。

但我發現它不適用於Firefox。

請注意。謝謝。

<object id="player" width="300" height="400" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"> 

    <PARAM NAME="stretchToFit" Value="1"> 
    ................... 
    <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" name="MediaPlayer" src="http://xxxxxxxxxxxxxx" 
    showcontrols="1" showpositioncontrols="0" showaudiocontrols="1" showtracker="0" showdisplay="0" showstatusbar="1" showgotobar="0" 
    showcaptioning="0" autostart="1" autorewind="0" animationatstart="0" transparentatstart="0" allowchangedisplaysize="0" 
    allowscan="0" enablecontextmenu="0" clicktoplay="0" width="300" height="400" stretchToFit="1"></embed> 

的jQuery/javascript代碼如下:

jQuery(document).ready(function() { 

     var height; 
     var width; 
     var paddingtop; 

     if (screen.width <= 1280) { 
      width = ($(window).width() - 20); 
      height = width/2; 
      paddtingtop = 4; 

     } 
     else if ((screen.width > 1280) && (screen.width < 1920)) { 
      width = ($(window).width() - 20); 
      height = width/1.7; 
      paddtingtop = 7; 

     } 
     else { 
      width = ($(window).width() - 20); 
      height = width/1.7; 
      paddtingtop = 7; 

     } 
     $("#player").css('width', width); 
     $("#player").css('height', height); 
     $("#player").css('padding-top', paddtingtop); 

    }); 
+0

您是否嘗試過增加了測量單元到你的寬度和高度?請提供一個測試用例... – feeela

+0

你知道你聲明瞭全局變量'paddingtop',然後你引用'paddtingtop',對吧? –

+0

另外,你最近的'else'語句是多餘的。 –

回答

0

對於你並不需要JavaScript來使其窗口寬度20像素的少你可以使用CSS的寬度。下面是一個簡單的例子:http://jsfiddle.net/m5GaA/

你可以找到一個更徹底的CSS的答案在這裏:xHTML/CSS: How to make inner div get 100% width minus another div width

除了否則最後已經提到的,在你的第二個的(screen.width> 1280),如果是superflous,條件已經由前面的if保證了。

你錯過了一個結束標記,這是你的網頁上缺少的嗎?這可能是原因。

我看不出爲什麼不行,但html/css可能是問題的根本原因,如果您仍然需要,請嘗試並提供演示。

的代碼的jsfiddle:

#HTML 
<div id=wrapper> 
    <div id=inner> 
    content must be present 
    </div> 
</div>​ 

#CSS 
#wrapper { 
    overflow:hidden; 
    background-color:red;   
    padding: 0px 10px 0px 10px; 
    width:100%; 
    height:100%;  
} 

#inner { 
    float:left; 
    background-color:blue;  
    width:100%; 
    height:100%; 
}