WP5.9更新之后,新版的后台编辑器,感觉style和主题不一致
wordpress吧
全部回复
仅看楼主
level 13
石中火_ 楼主
今天刚刚更新完WP,现在版本5.9
用缺省的后台编辑功能,发现怪怪的,主要是和主题的style相差一些。
我本来想尝试主题functions.php中
添加类似以下代码
function Bing_add_editor_style(){
add_editor_style('css/custom-editor-style.css');
}
add_action( 'after_setup_theme', 'Bing_add_editor_style' );
但我发现主题的functions.php中本身就有类似代码
现在问题,后台缺省编辑器宽度变成全屏宽度了,缺省的字体很小才13px
不知道怎么才能和主题尽量一致(想尽可能编辑时所见即所得)
有遇到同样问题的朋友么?
2022年01月26日 05点01分 1
level 1
遇到了一样的问题,你的解决了吗?
那个边距哪个文件夹可以改?现在是auto
editor-styles-wrapper .wp-block {
margin-left: auto;
margin-right: auto;
2022年01月28日 09点01分 2
解决了,看4楼。
2022年01月29日 00点01分
level 13
QQ273827769
2022年01月28日 23点01分 3
level 13
石中火_ 楼主
解决了,编辑器分两种,
一种是经典编辑器,需要functions.php中增加
function somefunction(){ add_editor_style('editor-style.css'); }
add_action( 'after_setup_theme', 'somefunction' );
而新的区块编辑器,需要在functions.php中增加
add_theme_support('editor-styles');
add_editor_style('editor-style.css');
新的5.9是FSE(full screen editor),修改content的宽度,你要直接改body的style
比如我的是下面这种:
hr.wp-block-separator { border: 1px solid;}
p.wp-block { font-family: "Open Sans", Arial, sans-serif; font-size: 17px; line-height: 1.6; color: #494949;}
body { width: 753px; border: 1px solid LightGrey; margin-left: auto; margin-right: auto; padding-left: 1.5625rem; padding-right: 1.5625rem;}
注意后台编辑器本身有缺省CSS,想自定义CSS的话,元素范围限定为类才能定位准确获得效果,比如前端CSS是h2 { font-size: 1.75em; },而后台编辑器CSS可能是h2.rich-text.block-editor-rich-text__editable { font-size: 1.75em; },记得多用F12。
2022年01月29日 00点01分 4
1