概述
wordpress的主题中必要文件为:style.css和index.php
下面就style.css的写法总结一下
style.css必须放在自定义主题的目录下
下面是wp官方2020主题的style.css的代码
/*
Theme Name: Twenty Twenty
Text Domain: twentytwenty
Version: 1.1
Requires at least: 4.7
Requires PHP: 5.2.4
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.
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
Author: the WordPress team
Author URI: https://wordpress.org/
Theme URI: https://wordpress.org/themes/twentytwenty/
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
All files, unless otherwise stated, are released under the GNU General Public
License version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html)
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned
with others.
*/
从中可以看到主题名称、主题链接、作者、作者链接、版本等等信息。
我们自定义主题的style.css的代码没必要写这么多,写出主题名称、作者、版本即可
/*
theme name:XXX职业技术学院
author:李书明
version:1.0
*/
/*--------------------------------------------------------------
>>> TABLE OF CONTENTS:
----------------------------------------------------------------
0. CSS Reset
----------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* 0. CSS Reset
/* -------------------------------------------------------------------------- */
html,
body {
border: none;
margin: 0;
padding: 0;
}
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
address,
big,
cite,
code,
em,
font,
img,
small,
strike,
sub,
sup,
li,
ol,
ul,
fieldset,
form,
label,
legend,
button,
table,
caption,
tr,
th,
td {
border: none;
font-size: inherit;
line-height: inherit;
margin: 0;
padding: 0;
text-align: inherit;
}
blockquote::before,
blockquote::after {
content: "";
}
在 WordPress 3.4 以上的版本中,我们可以直接使用 wp_get_theme() 这个函数来获取这些信息。以下是一些简单的例子:
获取当前主题名字:
| |
获取其它主题名字:
| |
获取当前主题版本号:
| |
显示当前主题作者的链接:
| |
最后
以上就是谨慎鞋垫为你收集整理的wordpress5.3主题开发第一课:style.css的写法的全部内容,希望文章能够帮你解决wordpress5.3主题开发第一课:style.css的写法所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复