儿童主题不是覆盖父母CSS



我已经创建了翻新主题的子主题。在孩子的主题文件夹中,我有一个" style.css"和一个" functions.php"文件。我的style.css看起来像这样:

/*
Theme Name: Renovation Child
Theme URI: http://renovation.thememove.com/
Author: ThemeMove
Author URI: http://thememove.com/
Version: 2.0.4
Template: tm-renovation
*/
/*
 * @charset "UTF-8";
*/
.vc_custom_1438936121266 {
    margin-bottom: 70px!important;
    padding-top: 65px!important;
    padding-bottom: 35px!important;
}

我的functions.php看起来像这样:

<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
// BEGIN ENQUEUE PARENT ACTION
if ( !function_exists( 'renovation_enqueue_scripts' ) ):
    function renovation_enqueue_scripts() {
        wp_enqueue_style( 'renovation-child-style', trailingslashit( get_stylesheet_directory_uri() ) . 'style.css' );
    }
endif;
add_action( 'wp_enqueue_scripts', 'renovation_enqueue_scripts' );
// END ENQUEUE PARENT ACTION

否则检查员我看到父级CSS首先被加载,看起来像这样:

.vc_custom_1438936121266 {
    margin-bottom: 70px!important;
    padding-top: 30px!important;
    padding-bottom: 35px!important;
}

我的CSS是在父级CSS之后加载的,看起来像是这样,除了全部杂交:

.vc_custom_1438936121266 {
    margin-bottom: 70px!important;
    padding-top: 65px!important;           <-- MY CHANGE
    padding-bottom: 35px!important;
}

我已经阅读了很多有关特殊性的线程,我注意到我的CSS和父级CSS是相同的,除了我所做的"填充"更改。由于孩子最后加载,我希望我的CSS优先考虑,但事实并非如此。我的CSS在检查员中被划掉,并正在使用父母。

这对我来说似乎不正确,我希望有人可以澄清我对父母/子女关系的理解,并帮助我解决这个问题。谢谢。

如果您仅覆盖一个元素而不将其应用于多个元素,则最好使用ID代替类。ID始终覆盖一个类。

最新更新