如何禁用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
相关产品推荐
相关产品推荐

