不能 100% 确定这个问题对于堆栈是否合法,但它不属于 Meta,它确实涉及一些代码,我不认为它是主观的 - 应该有一个答案......
我有一个使用 The7 主题的新 wordpress 网站,当然,我已经使用“One Click Child Theme”插件创建了一个子主题。
一切正常,我在其中放置了一些自定义 css 来调整导航并且它进行了调整,但是当我查看 chrome 中的 Inspector 时,我看到我的自定义 css 列出了两次!有人知道为什么吗?我的子样式表中没有任何额外的 import
语句,即使有,该代码也不在父样式表中。子样式表是否被加载了两次?
我知道很多网络代码,但对使用 Wordpress 还很陌生。这是正常行为吗?
这是我的整个子样式表:
/*
Theme Name: the7 Child
Description:
Author: chris@sqlfocus.com
Template: dt-the7
(optional values you can add: Theme URI, Author URI, Version, License, License URI, Tags, Text Domain)
*/
ul.main-nav {
padding-left: 100px;
padding-right: 100px;
-webkit-padding-start: 100px;
-webkit-padding-end: 100px;
}
函数.php:
<?php
//
// Recommended way to include parent theme styles.
// (Please see http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme)
//
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
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')
);
}
//
// Your code goes below
//
最佳答案
我在 Enfold 主题上遇到了完全相同的问题,而且我之前在其他主题上也遇到过。
我研究了一个页面的 HTML 输出,发现主题是自动包含我的样式表的。这是出乎意料的,因此也是不可取的,因为不可预测性是不可取的——并非所有主题都这样做。
修复?有点好笑……但我只是……
从 functions.php 中删除了我自己的引用,并让父主题为我自动包含它
悲伤但真实......
关于css - Wordpress 自定义 CSS 添加了两次?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36391271/