简体   繁体   English

在wordpress中应将style.css放在哪里

[英]Where style.css should be in wordpress

I am developing my own theme for wordpress, I'm also using SASS to write the CSS, and I want the final compiled CSS to be minified... my question is: 我正在为wordpress开发自己的主题,我也在使用SASS编写CSS,并且我希望最终编译的CSS最小化...我的问题是:

What would happen if I set SASS to compile the CSS in my style.css file (the one that is in the main folder of "themes"), would Wordpress be able to read it without problems? 如果我将SASS设置为在我的style.css文件(位于“主题”主文件夹中的文件)中编译CSS,Wordpress是否可以毫无问题地读取它?

Or should I leave style.css blank and compile the CSS in a file inside a CSS fodler, for example: css/main.css ? 还是应该将style.css保留为空白,然后将CSS编译到CSS格式文件中的文件中,例如: css/main.css

I would leave the style.css file alone and create another file like you stated. 我将不理会style.css文件并创建另一个文件,如您所述。 I'd also make sure to not include the default style.css and only the one you generated. 我还要确保不包括默认的style.css,而仅包括您生成的样式。 If you look at great starter themes, that is what they do. 如果您查看出色的入门主题,那么它们就是这样做的。 For example, https://github.com/roots/roots . 例如, https://github.com/roots/roots

Or should I leave style.css blank and compile the CSS in a file inside a CSS fodler, for example: css/main.css? 还是应该将style.css留为空白,然后将CSS编译到CSS改编器内的文件中,例如:css / main.css?

This is the best way to do it, and the way 99% of custom theme developers use. 这是最好的方法,也是99%的自定义主题开发人员使用的方法。 Just call main.css with @import and that's it 只需使用@import调用main.css就可以了

I think it depends on how large your css file will be. 我认为这取决于您的CSS文件的大小。 For larger projects, I would split up my stylesheets into global.css, layout.css, mobile.css, tablet.css, put them in a subdirectory and @import them into the main style.css in the theme's root folder. 对于较大的项目,我将样式表拆分为global.css,layout.css,mobile.css,tablet.css,将它们放在子目录中,然后将它们@import到主题根文件夹中的main style.css中。

If it is a simple site that doesn't require structuring your css in such a way, you can have style.css and style.sass located in the same root folder of your theme. 如果这是一个简单的站点,不需要以这种方式构造CSS,则可以将style.css和style.sass放在主题的同一根文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM