【发布时间】:2016-07-23 07:44:50
【问题描述】:
不是 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;
}
functions.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
//
【问题讨论】:
-
列出两次是什么意思?在呈现的规则中还是您看到两次 css 链接?
-
用我的检查员的图片更新了问题
-
共享
functions.php文件中的代码,您可以在其中将子主题的样式表排入队列 -
共享。看起来它只加载一次。
-
[crickets] 我不敢相信这超出了 SO 上每个人的知识范围