繁体   English   中英

style.css在wordpress中不起作用

[英]style.css didn't work in wordpress

我创建了三个文件: functions.phpstyle.cssheader.phpheader.php没有看到style.css

functions.php我写

/**
* Enqueue scripts and styles.
*/
function newtheme_scripts()
{
    wp_enqueue_style('newtheme-style', get_stylesheet_uri() );
}

add_action( 'wp_enqueue_scripts', 'newtheme_scripts' );

style.css文件

* {
    background-color: black;
}
.container-fluid {
    padding: 0px;
}

这也是我的header.php

<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Golden</title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
        <link rel="stylesheet" href="<?php echo get_stylesheet_uri() ?>">
        <?php wp_head(); ?>
    </head>
    <body>
        <div class="row header">...</div></body></html>

header.php中调用样式表的行应如下所示:

<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>">

首先,您无需在排队后调用样式表,wp_enqueue_scripts挂钩应将样式表调用注入到标头中的某个位置。

看起来您的标头已使用wp_head()正确设置; 在正确的区域致电。 但是,我认为罪魁祸首在于主题本身如何设置。

您已经提到您已经创建了这些文件(header.php,functions.php和style.css)...一般来说,这些文件应该已经在主题本身中为您创建了(除了style.css,如果您正在处理儿童主题)。

希望这可以帮助! 祝好运!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM