块编辑器古腾堡后台宽度

在使用一些非块主题的时候,又用到了块模块,一般主题不会在自定义里面增加相关全局设置的功能。如果要自己添加功能单独为了这一个宽度有点过于大题小作了,所以直接在块模式下修改宽度就行了,代码如下:

// 彻底强行覆盖古腾堡后台区块宽度(含 :where 选择器覆盖)
function override_gutenberg_editor_width() {
    wp_add_inline_style(
        'wp-block-library',
        '
       
        .wp-block-post-content,
        .block-editor-block-list__layout.is-root-container {
            max-width: 1200px !important;
            margin-left: auto !important;
            margin-right: auto !important;
        }

       
        html :where(.wp-block),
        .block-editor-block-list__layout .wp-block,
        .wp-block {
            max-width: 1200px !important;
        }

       
        .wp-block[data-align="wide"] { max-width: 1400px !important; }
        .wp-block[data-align="full"] { max-width: 100% !important; }
        '
    );
}
add_action('enqueue_block_editor_assets', 'override_gutenberg_editor_width');

这里是调整成了1200的宽度,全屏模式下是1400最大宽度,方便快捷,更多知识关注wordpress主题—欢喜开发。

欢喜开发 自2012
主题:260+ 销售:1000+
兼容浏览器

电话咨询

7*12服务咨询电话:

1855-626-3292

微信咨询

全站所有主题都可以免费获取,点击右侧查看获取方法。