Javascript CSS高度在firefox中不起作用

Javascript CSS高度在firefox中不起作用,javascript,jquery,asp.net,css,firefox,Javascript,Jquery,Asp.net,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.c

我在我的页面中嵌入了一个媒体播放器

我有一个解决方案,可以调整播放器的宽度和高度

但我发现它不存在;我不能在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);

    });
jQuery(文档).ready(函数(){
变异高度;
var宽度;
var paddingtop;
如果(屏幕宽度1280)和(屏幕宽度<1920)){
宽度=($(窗口).width()-20);
高度=宽度/1.7;
paddingtop=7;
}
否则{
宽度=($(窗口).width()-20);
高度=宽度/1.7;
paddingtop=7;
}
$(“#播放器”).css('width',width);
$(“#player”).css('height',height);
$(“#player”).css('padding-top',paddingtop);
});

对于不需要javascript的窗口宽度,您可以使用css使其小于20px。下面是一个简单的例子:

您可以在此处找到更全面的css答案:

正如前面提到的最后一个if一样,第二个if中的(screen.width>1280)是superflous,该条件已经由前一个if保证

您缺少一个结束标记您的页面上是否也缺少此标记?这可能是原因

我看不出还有什么其他方法不起作用,但html/css可能是问题的根本原因,如果您仍然需要,请尝试提供一个演示

JSFIDLE代码:

#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%;
}
#HTML
内容必须存在
​
#CSS
#包装纸{
溢出:隐藏;
背景色:红色;
填充:0px 10px 0px 10px;
宽度:100%;
身高:100%;
}
#内在的{
浮动:左;
背景颜色:蓝色;
宽度:100%;
身高:100%;
}

您是否尝试在宽度和高度中添加测量单位?请提供一个测试用例…您知道您声明了全局变量“paddingtop”,然后您引用了“paddingtop”,对吗?另外,您的最后一个
else
语句是多余的。