简体   繁体   English

TinyMCE正在改变我的内联CSS

[英]TinyMCE is changing my inline CSS

I input this in the HTML editor: 我在HTML编辑器中输入:

<p style="border:1px solid #edede4;border-top:none"></p>

I click update, and click the html editor again. 我单击更新,然后再次单击html编辑器。 The HTML (in Firefox) has changed to: HTML(在Firefox中)已更改为:

<p style="border-style: none solid solid; border-color: -moz-use-text-color rgb(237, 237, 228) rgb(237, 237, 228); border-width: medium 1px 1px;" mce_style="border:1px solid #edede4;border-top:none"><br></p>

If I do the same thing in Internet Explorer, the HTML changes to: 如果我在Internet Explorer中执行相同的操作,则HTML将更改为:

<P style="BORDER-RIGHT: #edede4 1px solid; BORDER-TOP: medium none; BORDER-LEFT: #edede4 1px solid; BORDER-BOTTOM: #edede4 1px solid" mce_style="border:1px solid #edede4;border-top:none">&nbsp;</P>

Why in the world does it change? 为什么世界会改变它? Maybe there are some TinyMCE settings i can change? 也许我可以改变一些TinyMCE设置? But I already have cleanup: false. 但我已经清理过了:假。 Ideas? 想法?

If I enable cleanup, the change I'm mentioning doesn't happen. 如果我启用清理,我提到的更改不会发生。 However, TinyMCE changes a lot of other stuff. 但是,TinyMCE改变了很多其他的东西。 I don't want it to mess with my code :( Any help would be appreciated. 我不希望它弄乱我的代码:(任何帮助将不胜感激。

Sometimes inline styles are neccessary as was the case for this project. 有时内联样式是必需的,就像这个项目的情况一样。
In this case I simply inserted html code piece by piece. 在这种情况下,我只是逐个插入HTML代码。 Instead of inserting: 而不是插入:

<p style="border:1px solid #edede4;border-top:none"></p>

I did something like this: 我做了这样的事情:

<p style=

"border:1px solid #edede4;border-top:none

"></p>

It's not perfect, but it works for this case as I don't want to change any TinyMCE settings. 它并不完美,但它适用于这种情况,因为我不想改变任何TinyMCE设置。 And it doesn't get recognised by TinyMCE as style code. 并且它不会被TinyMCE识别为样式代码。

Try setting verify_html to false. 尝试将verify_html设置为false。

Doc: TinyMCE Configuration/verify_html Doc: TinyMCE Con​​figuration / verify_html

When I have too many trouble with TinyMCE I just try to create other alternatives. 当我对TinyMCE有太多麻烦时,我只是尝试创建其他替代方案。 The "correct" way is to create a class in you css. “正确”的方法是在你的CSS中创建一个类。

Instead of: 代替:

<p style="border:1px solid #edede4;border-top:none"></p>

Use: 使用:

<p class="p_border"></p>

And declare in your css: 并在你的CSS中声明:

.p_border {
    border:1px solid #edede4;
    border-top:none;
}

Unfortunaly, you're doing a newsletter so you need inline. 不幸的是,你正在做一份时事通讯,所以你需要内联。 I haven't tested creating "style" tags before each "p" in this scenario with the class I declared above. 我没有测试在这个场景中每个“p”之前使用上面声明的类创建“样式”标签。 You could try to see if it works. 你可以试着看看它是否有效。

If it doesn't work, I would try to use "inline_styles : true". 如果它不起作用,我会尝试使用“inline_styles:true”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM