我使用Wordpress并且我有: -


 < meta name =“viewport”content =“width = device-width,initial-scale = 1”/>



 但响应不正常当我插入


 < link rel =“stylesheet”href =“<?php bloginfo('stylesheet_directory')?> /responsive.css” />



 或使用函数调用它,代码仍然可见但响应不正常...


之后,我尝试将文件responsive.css中的所有代码插入到带有< style>
标记的header.php中,然后它正在工作..
我想它的工作无需从文件中插入代码到header.php ..请帮帮我!感谢

答案 0 :(得分:0)
您应该使用适当的函数来排队脚本和样式表。我已在此函数中添加了bootstrap的依赖项,因此在bootstrap加载其样式表后会加载。将此代码放在functions.php文件中,我已经从CDN中添加了Bootstrap CSS作为示例。
add_action( 'wp_enqueue_scripts', 'child_enqueue_styles');
function child_enqueue_styles() {
wp_enqueue_style( 'bootstrap', 'https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css' );
wp_enqueue_style( 'responsive', get_template_directory_uri() . '/responsive.css', array('bootstrap') );
}