【问题标题】:Why noscript and skel are not working in wordpress?为什么 noscript 和 skel 在 wordpress 中不起作用?
【发布时间】:2014-05-11 14:11:45
【问题描述】:

我正在使用微型端口模板。 可以在here找到一个演示。

head 部分如下所示:

<!DOCTYPE HTML>
<!--
    Miniport 2.5 by HTML5 UP
    html5up.net | @n33co
    Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
-->
<html>
    <head>
        <title>Miniport by HTML5 UP</title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <meta name="description" content="" />
        <meta name="keywords" content="" />
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:300,600,700"       rel="stylesheet" />
        <script src="js/jquery.min.js"></script>
        <script src="js/config.js"></script>
        <script src="js/skel.min.js"></script>
        <noscript>
            <link rel="stylesheet" href="css/skel-noscript.css" />
            <link rel="stylesheet" href="css/style.css" />
            <link rel="stylesheet" href="css/style-desktop.css" />
        </noscript>
        <!--[if lte IE 9]><link rel="stylesheet" href="css/ie9.css" /><![endif]-->
        <!--[if lte IE 8]><script src="js/html5shiv.js"></script><link rel="stylesheet" href="css/ie8.css" /><![endif]-->
        <!--[if lte IE 7]><link rel="stylesheet" href="css/ie7.css" /><![endif]-->
    </head>

没有任何变化,但在将其转换为 wordpress 主题时添加了&lt;?php wp_head(); ?&gt;。 但是css坏了,当&lt;noscript&gt;在那里时,看起来页面没有得到css。 将原始主题转换为 wordpress 时,响应性也会中断。 如何解决 1.noscript 问题 2. 响应性问题?

【问题讨论】:

    标签: jquery css wordpress wordpress-theming noscript


    【解决方案1】:

    您以错误的方式调用样式表。将 css 调用更改为:

    <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/skel-noscript.css" />
    <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/style.css" />
    <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/style-desktop.css" />
    

    但我建议您在索引文件夹中创建一个 style.css,然后将 @import 用于其他工作表。为此,将调用更改为:

    <link rel="stylesheet" type="text/css" media="screen" href="<?php bloginfo('stylesheet_url'); ?>" />
    

    注意:对 js 文件做同样的事情。

    <script src="<?php bloginfo('template_url'); ?>/js/jquery.min.js"></script>
    <script src="<?php bloginfo('template_url'); ?>/js/config.js"></script>
    <script src="<?php bloginfo('template_url'); ?>/js/skel.min.js"></script>
    

    【讨论】:

    • 我展示的脚本只是 html 脚本。顺便说一句,调用样式表和 js 的最佳实践是在 functions.php 中使用 wp_enqueue_style 和 wp_enqueue_script。
    猜你喜欢
    • 2011-11-19
    • 2014-08-02
    • 1970-01-01
    • 1970-01-01
    • 2014-11-07
    • 1970-01-01
    • 1970-01-01
    • 2018-04-28
    • 1970-01-01
    相关资源
    最近更新 更多