在页面中插入代码<style>时响应刚刚激活

时间:2018-04-14 04:09:16

标签: php wordpress twitter-bootstrap twitter-bootstrap-3 wordpress-theming

我不明白!请帮助我...

&#xA;&#xA;

我使用Wordpress并且我有: -

&#xA;&#xA;
 &lt; meta name =“viewport”content =“width = device-width,initial-scale = 1”/&gt;&#xA;  
&#xA;&#xA;

但响应不正常当我插入

&#xA;&#xA;
 &lt; link rel =“stylesheet”href =“&lt;?php bloginfo('stylesheet_directory')?&gt; /responsive.css” /&gt;&#xA;  
&#xA;&#xA;

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

&#xA;&#xA;

之后,我尝试将文件responsive.css中的所有代码插入到带有&lt; style&gt; 标记的header.php中,然后它正在工作..

&#xA;&#xA;

我想它的工作无需从文件中插入代码到header.php ..请帮帮我!感谢

&#XA;

1 个答案:

答案 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') );

}