添加样式:ckeditor中图像的最大宽度

问题描述 投票:0回答:1

enter image description here

我想在 Ckeditor 中为图像自动添加 max-width:100% 属性。

但是当我提交并保存后,这个属性就消失了。 我想定制它。 谢谢大家 最好的问候

ckeditor4.x
1个回答
0
投票

我认为你不应该在使用 ckeditor 制作内容时这样做,而是在提交此 html 后以及在保存之前这样做。

例如,通过利用抓取库或通过句柄搜索 img在准备好的ckeditor html代码中,您可以使用'style'属性进行一些操作。


另一种方法 - 是通过页面上的某些样式表覆盖 img 对象样式,您要在其中显示 ckeditor 内容。

.html

<div id="content">
    **ckeditor html**
</div>

.css

#content img {
    max-width: 100% !important;
    height: auto !important;
}

也许您当然可以通过使用 ckeditor 插件或覆盖配置来在 ckeditor 端进行更改,但这可能会带来意想不到的问题。

© www.soinside.com 2019 - 2024. All rights reserved.