【问题标题】:bootstrap 3 to wordpress theme Conversion. WordPress can't catch my bootstrap stylesheetbootstrap 3 到 wordpress 主题的转换。 WordPress 无法捕获我的引导样式表
【发布时间】:2013-11-13 04:10:05
【问题描述】:

我只是用 bootstrap 3 制作了一个 html 网站。现在我正在尝试制作它的 wordpress 主题。我将 index.html 制作为 index.php 并制作了一个名为“style.css”的 css 文件

在 style.css 中,我像这样导入我的引导 css 文件:

@import url('css/bootstrap.css');
@import url('css/bootstrap.min.css');

然后我将主题上传到服务器上。我激活了主题。但我的网站看起来没有任何 CSS。这似乎是一个没有任何 CSS 的 html 网站。我尝试了很多方式,但不明白为什么我的主题找不到 css。我还没有对我的主题做任何改变,比如在我的主题中使用 php 函数。

如果你知道这个问题的解决方案,请帮助我。

【问题讨论】:

    标签: html wordpress twitter-bootstrap


    【解决方案1】:

    使用 WP enqueue_scripts 函数将 bootstrap css/js 包含在 functions.php 中

    function add_style() {
    
    wp_register_style('bootstrap-css',get_template_directory_uri()."/css/bootstrap.css");
    wp_register_style('bootstrap-min-css',get_template_directory_uri()."/css/bootstrap.min.css");
    
    wp_enqueue_style( 'bootstrap-css' );
    wp_enqueue_style( 'bootstrap-min-css' );
    }
    
    add_action('wp_enqueue_scripts', 'add_style');
    

    【讨论】:

      【解决方案2】:

      您需要使用<link rel="stylesheet" type="text/css" href="/pathtothecss/theme.css"> 将 style.css 链接到 HTML

      我建议你不要使用@import。只需将所有 css 样式表链接到您网站的 <head> 部分。

      【讨论】:

        【解决方案3】:

        @import url('/css/bootstrap.min.css');

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-05-29
          • 1970-01-01
          • 2014-11-10
          • 2019-03-28
          • 2014-12-02
          • 2016-01-16
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多