前言There\'s no WordPress-specific stuff in this answer, 但我只是想帮忙,因为官方文件(就写作而言)没有太大帮助。。
但正如我在评论中所说,我不使用Elementor,这意味着我对Elementor的技术知识了解不多。(实际上,即使是非技术性的……))
的$query 需要一个min/max 和a“;“设备”
因此
add_rules() Elementor中的方法
stylesheet class 正在使用
add_query_hash() 和
hash_to_query() 方法,然后我检查了源代码并注意到:
在$query 数组(第三个参数add_rules() 方法)应具有min 或max 项目,例如。\'min\' => 600 或\'max\' => 799, 或者两者兼而有之。
需要有一个;“设备”;名称与min/max 中的值$query 大堆以及注册海关;“设备”;,您可以使用add_device() 该类中的方法。
此外max 中的值$query 阵列必须在设备大小的范围内。例如,在下面的示例中max 是799, 因此,最大设备大小必须为800 或更多。
用于测试add_rules():测试正常,但没有使用实际的Elementor插件进行尝试
$css = new Stylesheet;
$css->add_device( \'600\', 600 );
$css->add_device( \'800\', 800 );
// Outputs @media(min-width:600px){#foo{width:300px;}}
$css->add_rules( \'#foo\', [
\'width\' => \'300px\',
], [
\'min\' => 600,
] );
// Outputs @media(max-width:799px){#foo{height:400px;}}
$css->add_rules( \'#foo\', [
\'height\' => \'400px\', // this is merely a test
], [
\'max\' => 799,
] );
echo $css; // echoes the CSS media queries above
// It works because the class has a __toString() method.
快乐的编码!