2014-01-06 47 views
0

一個WordPress主題的特定樣式表文件具有下面的代碼覆蓋CSS高度0和寬度0 I幀

.padder iframe { 
    height: 0; 
    width: 0; 
} 

我想在一個自定義的CSS文件來覆蓋此顯示視頻嵌入標籤與高度&寬度屬性。

<iframe src="...." width="600" height="338" frameborder="0" title="...." webkitallowfullscreen mozallowfullscreen allowfullscreen> 

我試圖autoheightwidth,但都使I幀小。

如果這在CSS中不可行我已經準備好嘗試jQuery解決方案了。

+0

如果你想縮放iframe大小的內容,這不是那麼容易? – adeneo

+0

@adeneo我試圖將iframe縮放到其高度和寬度屬性中提到的靜態大小。 –

回答

1

iframe寬度和高度屬性不會覆蓋CSS的。試試這個:

<iframe style="width: 600px; height: 338px" ... 

如果還是不行,請張貼CSS覆蓋你嘗試和檢查0高度/寬度不被你的CSS加載後(嘗試Firefox或Chrome開發者工具)

您是否考慮過最小寬度和最小高度?

一個jQuery的解決方案,如果一切都失敗了:

jQuery('iframe').each(function() { 
    var $this = jQuery(this); 
    var w = $this.prop('width'); 
    var h = $this.prop('height'); 
    $this.css({width: w + 'px', height: h + 'px'}); 
}); 
0

舉一個ID到iframe和嘗試

#iframe_id{ 
height: 200px; 
width: 200px; 
} 

#iframe_id{ 
height: 200px !important; 
width: 200px !important; 
} 
+0

在樣式表中使用固定的高度和寬度不是選項。 WordPress動態設置尺寸並以高度和寬度屬性的形式將其打印在前端。 –

相關問題