2016-11-17 50 views
0

我在jsp中使用tinymce textareas。我只想在一个textarea中应用css样式。tinymce textarea body-class不适用

textarea的定义是

tinymce.init({ 
     selector : "textarea", 
     body_class: 'text1=styleTextArea' 

    }); 

JSP中的样式定义是

.styleTextArea { 
    color: #000; 
    font-family: Verdana,Arial,Helvetica,sans-serif; 
    font-size: 14px; 
} 

我与Firefox浏览器。在导航控制台Firefox中的输出是:

<body id="tinymce" class="mce-content-body styleTextArea" data-id="text1" spellcheck="false" contenteditable="true"> 
<p> </p></body> 

但styleTextArea风格并不适用,因为字体大小是不是14

如何申请体类只ID textarea的TinyMCE的

在JSP

<textarea path="text1" 
          name="text1" id="text1"> 

       </textarea> 

定义文本1 EDITED

我在路径中的CSS /resources/css/textarea.css

我修改了JSP与

tinymce.init({ 
     selector : "textarea", 
     body_class: 'text1=/resources/css/textarea.css' 



    }); 

这是浏览器导航

<body id="tinymce" class="mce-content-body /resources/css/textarea.css" data-id="text1" spellcheck="false" contenteditable="true"> 
<p></p></body> 

我不明白很好地如何应用这个类。

回答

0

body_class(和body_id)配置选项不应引用它们被简单地用于定义CSS文件classid应该在编辑器被施加到<body>标签:

https://www.tinymce.com/docs/configure/content-appearance/#body_class https://www.tinymce.com/docs/configure/content-appearance/#body_id

例如:

tinymce.init({ 
    selector: 'textarea', 
    body_id: 'my_id' 
}); 

...或...

tinymce.init({ 
    selector: 'textarea', 
    body_class: 'my_class' 
}); 

单独从这个,你可以使用content_css配置选项来定义CSS应用到classid您通过外部CSS文件添加到<body>标签。例如:

tinyMCE.init({ 
    selector: 'textarea', 
    content_css : 'myCusomStyles.css' 
}); 

您使用的CSS文件应该有声明该样式classid您分配:

body.my_class { 
    background-color: yellow; 
}