2013-10-15 36 views
0

我已經通過一個CSS文件路徑到我的CKEditor實例contentsCss選項,這很好。但是,我需要能夠動態地添加更多我不能添加到CSS文件中的樣式。在版本3中,它看起來像可以使用addCss函數(see this forum post)。不幸的是,這在版本4中似乎不起作用(see this forum post)。有沒有人有另一種選擇?我正在使用jQuery適配器,因此使用任一API的解決方案都可以工作。動態添加內容風格到CKEditor 4實例

+0

'.addClass('large')' –

+0

@SethMcClaine我可以使用'.css'函數來應用打印樣式嗎? – theblang

+0

檢查這個傢伙,讓我知道它是否有幫助 http://stackoverflow.com/questions/7765866/append-stylesheet-link-for-printing-triggered-on-jquery-click-event –

回答

0

我認爲,如果你有jQuery的你可以使用CSS功能'的.css( '高度', '23像素')`或addClass功能,你可以這樣做

$(window).on('print',function(e){ 
    e.preventDefault(); 
    var styles = '<style>'+/*calculation of styles*/+'</style>' 
    $('head').append(styles); 
    window.print(); 

}); 

$(window).on('load',function(e){ 
    var styles = '<style>'+/*calculation of media query print styles*/+'</style>' 
    $('head').append(styles); 

}); 
+0

我不認爲這會起作用,因爲我告訴CKEditor要通過JavaScript使用哪個CSS文件。它不使用頁面上的任何樣式。 – theblang