Avada(Wordpress主题)编译CSS:它从哪里编译?

时间:2016-12-26 23:43:35

标签: css woocommerce wordpress-theming

我们最近将Wordpress电子商务网站(woocommerce)从旧的/错误的自定义主题迁移到Avada。
我们很容易在Fusion Builder中重建了所有内容(页面和产品),并且使用自定义CSS进行调整非常简单。

但是有一些松散的线程,其中一个让我完全难过。

有一个WooCommerce元素在某个地方被设计 .product .entry-summary div .price{}
我无法覆盖它(尝试!important),而我似乎无法找到规则 最初 所写的内容。

话虽这么说,当我用浏览器工具检查时,流行规则见于 “.../wp-content/uploads/avada-styles/avada-1069.css”。
当我打开CSS时,文档顶部有一个完整的块,上面写着:
/********* Compiled - Do not edit *********/

该目录中有大量“Avada - ###。css”文件 他们似乎都有一些编译规则。

从哪里汇编?
我在哪里可以找到正确编辑它的源文件?!

注意:

我曾两次尝试联系主题融合支持(Avada主题的作者),但没有收到任何回复。
已经好几周了,所以现在我很绝望。

2 个答案:

答案 0 :(得分:3)

/avada-1069.css文件的来源。

/*** Compiled - Do not edit ***/让你知道该文件是主题核心的一部分。当Avast更新时可能会覆盖对其的更改,并且可能会破坏功能。

如果您需要进行主题自定义CSS字段不支持的更改,请创建基本child-theme。样板函数.php和styles.css代码就足够了:

<?php
function my_theme_enqueue_styles() {

    $parent_style = 'parent-style';

    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style ),
        wp_get_theme()->get('Version')
    );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
?>

/*
 Theme Name:   Avast Child
 Theme URI:    http://example.com/avast-child/
 Description:  My First Child Theme :)
 Author:       John Doe
 Author URI:   http://example.com
 Template:     avast
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Tags:         whatever, blah
 Text Domain:  avast-child
*/

.product .entry-summary div .price{ ... }

子主题CSS表单中的语句将覆盖父表单中的语句。当主题更新时,您的孩子将保持不变并继续完成它的工作。

在此之前,您可以通过查看Specifics on CSS Specificity获益。它打破了覆盖层次结构。您还可以发布规则的代码和人们可以查看的源规则。

答案 1 :(得分:0)

似乎主题是动态生成样式表,因此直接编辑不会成为一个选项(因为它们无论如何都会改变)。

我不确定所有动态样式表的加载方式,但WordPress的方法是首先使用child theme ,然后:

  1. 为您的子主题style.css和/或
  2. 添加覆盖样式
  3. 完全从您孩子主题的functions.php文件中取消注册父主题的样式表,并在子主题style.css中使用您自己的样式:
  4. (其中avada-dynamic-css是主题注册的句柄)

    function yourname_unhook_parent_style() {
      wp_dequeue_style( 'avada-dynamic-css' );
      wp_deregister_style( 'avada-dynamic-css' );
    }
    add_action( 'wp_enqueue_scripts', 'yourname_unhook_parent_style', 20 );