【问题标题】:How to add Responsive.css in Custom Wordpress Theme如何在自定义 Wordpress 主题中添加 Responsive.css
【发布时间】:2016-11-11 01:13:21
【问题描述】:

我是 wordpress 的新手。我创建了一个包含style.cssheader.phpindex.phpfooter.php 的wordpress 主题。现在我想让我的index.php 页面响应,因为在调整 index.php 的浏览器窗口布局后变得很糟糕(在移动设备和其他手柄设备上无法正确查看)。

我想借助 @media 查询或引导程序使 index.php 响应。

请建议我如何使 index.php 成为响应式页面?

【问题讨论】:

  • 使用媒体查询。为 HTML 元素提供 id 和 class。媒体查询是让网站响应式更新的好方法。
  • 好的。如何将 responsive.css 页面与自定义 wordpress 页面链接。将 style.css 与自定义 wordpress 链接的代码是:"" 所以我如何链接响应式 css与页面。

标签: css wordpress twitter-bootstrap responsive-design media-queries


【解决方案1】:

您需要在主题文件夹中的 functions.php 文件中使用 wp_enqueue_style() 函数注册您的 responsive.css 工作表。如果您没有此文件,只需创建它:

<?php

// Enqueue your files
function theme_enqueue_styles() {
    // If the current page is the homepage, then load the responsive.css file
    if(is_home()) {
        wp_enqueue_style( 'responsive', get_stylesheet_directory_uri() . '/css/responsive.css' );
    }
}

// Add action
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles', 15 );

然后您需要创建您的theme/css/responsive.css 文件并为您编写媒体查询和样式。

希望这会有所帮助!

【讨论】:

  • 好的。如何将 responsive.css 页面与自定义 wordpress 页面链接。将 style.css 与自定义 wordpress 链接的代码是:"" 所以我如何链接响应式 css有页面
  • 编辑答案:您可以尝试使用is_home()函数检查当前页面是否为首页
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-12-30
  • 1970-01-01
  • 2016-11-12
  • 1970-01-01
  • 1970-01-01
  • 2014-05-23
  • 1970-01-01
相关资源
最近更新 更多