【问题标题】:Avada (Wordpress theme) compiled CSS: where does it compiled from?Avada(Wordpress 主题)编译的 CSS:它是从哪里编译的?
【发布时间】:2017-05-11 06:41:07
【问题描述】:

我们最近将我们的 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 主题的作者),但未收到任何回复。
已经好几个星期了,所以现在我很绝望。

【问题讨论】:

    标签: css woocommerce wordpress-theming


    【解决方案1】:

    /avada-1069.css 文件来源。

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

    如果您需要进行主题的自定义 CSS 字段不支持的更改,请创建一个基本的child-theme。样板的functions.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。它分解了覆盖层次结构。您还可以发布您的规则的代码和源规则供人们查看。

    【讨论】:

    • 事实证明,毕竟,我的问题是 chaching ...以为我们已经解决了这个问题,但忘记了他们已经添加了 CDN 层 :j -- 谢谢@mikerose 的回复。您完美地回答了我提出的问题,因此我将其标记为已接受的答案。
    • AVADA 在其子主题中提供的functions.php 似乎已损坏!我刚刚换掉了带有 Avada 子主题的这个通用样板,它工作正常。
    【解决方案2】:

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

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

    1. 将覆盖样式添加到您的子主题的style.css 和/或,
    2. 从您的子主题的functions.php 文件中完全取消注册父主题的样式表,并在子主题style.css 中使用您自己的样式:

    (其中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 );
    

    【讨论】:

    • 是的。 a) 这些是动态生成的。直接编辑不是一种选择。 b)我们正在使用儿童主题。 - 感谢functions.php 的见解...我会调查的
    猜你喜欢
    • 2010-11-15
    • 2022-12-16
    • 2017-08-08
    • 1970-01-01
    • 2017-02-11
    • 1970-01-01
    • 2021-07-01
    • 1970-01-01
    • 2015-03-23
    相关资源
    最近更新 更多