【问题标题】:Child Theme CSS not being applied未应用子主题 CSS
【发布时间】:2017-06-15 00:54:59
【问题描述】:

我有一个儿童主题,我正在使用 221。它已被检查为 CSS 级别 3 有效且无错误。

/* Minimum width of 600 pixels. */
@media screen and (min-width: 600px) {
.site {
    margin: 0 auto;
    max-width: 960px;
    max-width: 68.571428571rem;
    overflow: hidden;
}

在我正在积极使用的子主题中,即使导入了原版,我也放置了以下内容

/* Minimum width of 600 pixels. */
@media screen and (min-width: 600px) {
/*BEGIN MY RESET*/

/*Site background overall*/
.site {
max-width: 100% !important;
background-color: #fff;
}

但是似乎只有前者生效,而后者似乎没有从我正在使用的子主题中应用。

有人请指教吗?

我的孩子主题 css:view-source:http://stanleyss.com/wp-content/themes/twentytwelvechild/style.css

我的父主题 css:http://stanleyss.com/wp-content/themes/twentytwelve/style.css

【问题讨论】:

    标签: wordpress css wordpress-theming child-theming


    【解决方案1】:

    我认为您对包含子样式表感到困惑,请检查您使用什么函数在您的 functions.php 文件中包含子样式表。 如果你使用

    wp_enqueue_style( 'your-style-handler', get_template_directory_uri() . '/style.css' );
    

    然后用

    更改此代码
    wp_enqueue_style( 'your-style-handler', get_stylesheet_directory_uri() . '/style.css' );
    

    get_template_directory_uri() 用于包含父主题文件,get_stylesheet_directory_uri() 用于包含子主题文件。

    【讨论】:

    • 感谢 @nahid-hasan 二十二已更新且未改动,在 functions.php 中我有 // Loads our main stylesheet. wp_enqueue_style( 'twentytwelve-style', get_stylesheet_uri() ); 任何其他想法?
    猜你喜欢
    • 1970-01-01
    • 2018-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-18
    • 1970-01-01
    • 1970-01-01
    • 2017-06-22
    相关资源
    最近更新 更多