我在网站上使用Divi儿童主题。我添加了Bootstrap来创建联系表单。但是,只要我使用wp_enqueue_style和wp_enqueue_script将样式和脚本排入队列,顶部导航就会在悬停时获得一些额外的填充和背景颜色。
您可以通过加载live site和dev site并比较它们来查看差异。
这是我在子主题中的functions.php文件中的排队代码。当我运行它并查看源代码时,它似乎确实将主要的style.css放在bootstrap css之后,这是我所理解的,以确保style.css在这里具有特异性。我错过了什么?
// Enqueue Bootstrap for modal popup contact form
function wpbootstrap_scripts_with_jquery()
{
wp_enqueue_script( 'bootstrap-js', '//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js' );
wp_enqueue_style( 'bootstrap-css', '//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' );
}
add_action( 'wp_enqueue_scripts', 'wpbootstrap_scripts_with_jquery' );
// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED - Do not modify or remove comment markers above or below:
if ( !function_exists( 'chld_thm_cfg_parent_css' ) ):
function chld_thm_cfg_parent_css() {
wp_enqueue_style( 'chld_thm_cfg_parent', trailingslashit( get_template_directory_uri() ) . 'style.css', array( ) );
}
endif;
add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css' );
if ( !function_exists( 'child_theme_configurator_css' ) ):
function child_theme_configurator_css() {
wp_enqueue_style( 'chld_thm_cfg_separate', trailingslashit( get_stylesheet_directory_uri() ) . 'ctc-style.css', array( 'chld_thm_cfg_parent','divi-style','et-shortcodes-css','et-shortcodes-responsive-css','magnific-popup' ) );
}
endif;
add_action( 'wp_enqueue_scripts', 'child_theme_configurator_css' );
// END ENQUEUE PARENT ACTION
答案 0 :(得分:0)
我最近才遇到这种情况,我发现:
wp_enqueue_scripts
添加脚本wp_enqueue_scripts
的版本。wp_enqueue_style
的版本。在下面的代码中注意1.0.3
。我完整的工作代码是未被其他类覆盖的
function wp_enquene_bulma_css() {
wp_enqueue_style( 'bulma', '/wp-content/themes/twentyseventeen-child/css/bulma.min.css', false, '1.0.3', 'all' );
}
add_action('wp_enqueue_scripts', 'wp_enquene_bulma_css');