1-3 wordpress主样式表(style.css)

style.css 是每个 WordPress 主题所需的样式表 (CSS) 文件。 它控制网站页面的展示(视觉设计和布局)。

一、位置

为了让 WordPress 将主题模板文件集识别为有效主题,style.css 文件需要位于主题的根目录中,而不是子目录中。

二、基本结构

WordPress 使用 style.css 的标题注释部分在外观(主题)仪表板面板中显示有关主题的信息。

1、例如

这是 style.css 的标头部分的示例。

 1 /*
 2 Theme Name: Twenty Twenty
 3 Theme URI: https://wordpress.org/themes/twentytwenty/
 4 Author: the WordPress team
 5 Author URI: https://wordpress.org/
 6 Description: Our default theme for 2020 is designed to take full advantage of the flexibility of the block editor. Organizations and businesses have the ability to create dynamic landing pages with endless layouts using the group and column blocks. The centered content column and fine-tuned typography also makes it perfect for traditional blogs. Complete editor styles give you a good idea of what your content will look like, even before you publish. You can give your site a personal touch by changing the background colors and the accent color in the Customizer. The colors of all elements on your site are automatically calculated based on the colors you pick, ensuring a high, accessible color contrast for your visitors.
 7 Tags: blog, one-column, custom-background, custom-colors, custom-logo, custom-menu, editor-style, featured-images, footer-widgets, full-width-template, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready, block-styles, wide-blocks, accessibility-ready
 8 Version: 1.3
 9 Requires at least: 5.0
10 Tested up to: 5.4
11 Requires PHP: 7.0
12 License: GNU General Public License v2 or later
13 License URI: http://www.gnu.org/licenses/gpl-2.0.html
14 Text Domain: twentytwenty
15 This theme, like WordPress, is licensed under the GPL.
16 Use it to make something cool, have fun, and share what you've learned with others.
17 */

WordPress 主题存储库使用此文件中“版本”后面的数字来确定主题是否有可用的新版本。

2、解释

带有 (*) 的项目是 WordPress 主题存储库中的主题所必需的。

  • 主题名称 (*):主题的名称。
  • 主题 URI:公共网页的 URL,用户可以在其中找到有关主题的更多信息。
  • 作者 (*):开发主题的个人或组织的名称。建议使用主题作者的 wordpress.org 用户名。
  • 作者 URI:作者个人或组织的 URL。
  • 描述 (*):主题的简短描述。
  • 版本 (*):主题的版本,以 X.X 或 X.X.X 格式编写。
  • 至少需要 (*):主题将使用的最旧的主 WordPress 版本,以 X.X 格式编写。主题只需要支持最后三个版本。
  • 测试到 (*):主题已测试到的最后一个主要 WordPress 版本,即 5.4。只写数字,X.X 格式。
  • 需要 PHP (*):支持的最旧的 PHP 版本,X.X 格式,只有数字
  • 许可证 (*):主题的许可证。
  • 许可证 URI (*):主题许可证的 URL。
  • 文本域 (*):用于文本域进行翻译的字符串。
  • 标签:允许用户使用标签过滤器找到主题的单词或短语。完整的标签列表在主题审查手册中。
  • 域路径:用于使 WordPress 在主题被禁用时知道在哪里可以找到翻译。默认为 /languages。

在所需的标头部分之后,style.css 可以包含常规 CSS 文件具有的任何内容。

三、用于子主题的 Style.css

如果您的主题是子主题,则 style.css 标头中需要 Template 行。

1 /*
2 Theme Name: My Child Theme
3 Template: twentytwenty
4 */

 

posted @ 2022-03-08 14:59  Arya-Wang  阅读(353)  评论(0)    收藏  举报