2016-05-18 49 views
1

我試圖在加載後使用jQuery將一些元素添加到iframe中。元素類在通過jquery添加到iframe後未加載其CSS屬性

$('#container')。html('')。添加的元素出現在頁面上,但類不加載CSS屬性!任何人都可以解釋一下這個問題嗎?

這是類

.player {寬度:150像素; height:30px; background-image:url(../ img/bg.svg); background-repeat:no-repeat;填充:5px的;}

這是怎麼顯示 enter image description here

這是它是如何應該是

enter image description here

+0

我想我必須補充說,這個問題發生在AngularJS指令中的Iframe中! – limpCoder

回答

0

你加載正確的CSS? 你有沒有嘗試改變類名,然後將CSS應用到它? 你試圖改變這樣的CSS:

`iframe { 
width: 150px; 
height: 30px; 
background-image: url(../img/bg.svg); 
background-repeat: no-repeat; 
padding: 5px; 
}` 

嘗試將沒有類的iframe放入div中,然後在CSS文件中調用它。

`<div class="iframewrap"> 
    <iframe></iframe> 
</div> 

    .iframewrap iframe { 
    width: 150px; 
    height: 30px; 
    background-image: url(../img/bg.svg); 
    background-repeat: no-repeat; 
    padding: 5px; 
    }` 
+0

不幸的是,沒有幫助! – limpCoder