You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何禁用Elementor维度控制中的指定字段?

禁用Elementor维度控制特定字段的方法

要禁用Elementor维度控制中的特定字段,只需在add_responsive_control的参数里添加allowed_dimensions选项,指定允许保留的维度字段即可,未被列入的字段会被自动隐藏。

比如你要禁用右侧(right)的维度控制,修改后的代码如下:

$this->add_responsive_control(
    'margin',
    [
        'label' => esc_html__('Margin', 'textdomain'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px', '%', 'em', 'rem', 'custom'],
        // 指定允许的维度字段,未列出的将被禁用
        'allowed_dimensions' => ['top', 'bottom', 'left'],
        'selectors' => [
            '{{WRAPPER}} .your-class' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
    ]
);

参数说明:

  • allowed_dimensions的可选值为top、right、bottom、left,你可以根据需求组合这些值,只保留需要显示的维度字段。

内容的提问来源于stack exchange,提问作者Rasel Sheikh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 23:44:52