css不影响新的页面模板


style.css not affecting new page template

我已经添加了一个新的模板到我的主题文件夹login.php。

下面是login.php的代码:

<?php
/**
 * Template Name: login
 * Description: login page
 * @package Backyard Cures
 */
?>
<?php get_header(); ?>
@import url("./wp-content/themes/backyard-cures/style.css")
<div class="all-content">
<div class="all-content-container">    
    <?php wp_login_form(); ?>
    <?php get_sidebar(); ?>
    <?php wp_footer(); ?>
我有两个问题,也许它们是相关的。

1)当我打开登录页面时,chrome开发人员没有注册全内容和全内容容器div。

2)当我尝试在login.php使用style.css样式的元素,这些变化不显示。事实上,chrome开发人员似乎根本没有注册任何css。

Thanks in advance

@import仅在css文件中使用时有效。要在页面中包含css,您需要这样做:

<link rel="stylesheet" type="text/css" href="./wp-content/themes/backyard-cures/style.css"/>

通常@import仅在css文件中使用时有效。要在你的页面中包含css,你需要像这样包含它:

<link rel="stylesheet" type="text/css" href="./wp-content/themes/backyard-cures/style.css"/>

您可以在http://gajjar.me/1tkqiLg阅读更多关于@import的信息

你是说你的CSS文件没有加载吗?如果是这样,请尝试bloginfo。这将动态地为你的模板目录创建引用。

<link href="<?php bloginfo('template_directory');?>/style.css" rel="stylesheet">

这是一个方便的小WP APIhttp://codex.wordpress.org/Function_Reference/bloginfo

将您的import css更改为
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url') ?>/style.css" />
别忘了关上你的潜水器</div>