如何在wordpress主题中添加额外的CSS?

fun*_*guy 1 wordpress

我在平板电脑和上网本上检查了我的博客,它看起来有点不好,所以我做了一个额外的CSS并添加到header.php之间:

<head>
<link media="all and (min-width: 481px) and (max-width: 768px)" type="text/css" rel="stylesheet" href="tablet.css">
</head>
Run Code Online (Sandbox Code Playgroud)

但没有任何反应.如何添加一个额外的.css来使其工作?

还尝试将此功能添加到主题functions.php,但博客崩溃.

wp_enqueue_style('my-custom-style', 'get_bloginfo('template_url') . '/css/tablet.css',false,'1.1','all and (min-width: 481px) and (max-width: 768px)');
Run Code Online (Sandbox Code Playgroud)

我应该在'template_url'中添加什么,以及实现目标的最简单方法是什么?

谢谢!

Spa*_*kup 6

试试这个 :

<link rel="stylesheet" type="text/css" href="path/to/your/css/file.css">
Run Code Online (Sandbox Code Playgroud)

将它添加到您的模板header.php文件,后<?php wp_head(); ?>您的最后一个样式表.

如果失败则在</head>标记之前添加它.

如果您不确定使用完整路径,也可以使您的样式表路径正确无误:

<link rel="stylesheet" type="text/css" href="http://www.site.com/path/file.css">
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你