简体   繁体   English

定制器中的Wordpress内联样式在生产中

[英]Wordpress inline styles from Customizer in production

I am relatively new in web development. 我在Web开发方面相对较新。 I have question more about best practices and common patterns. 我对最佳做法和常见模式有更多疑问。

I am using wordpress, I found free theme and using it like starting point to build web site. 我正在使用wordpress,我发现了免费的主题并将其用作构建网站的起点。 This theme provides possibility to configure it using Customizer , so you can just change values in interactive mode to apply settings. 该主题提供了使用Customizer对其进行配置的可能性,因此您只需在交互模式下更改值即可应用设置。

And than this goes into header inline css style so all styles are stored directly in html and for sure they override styles defined in css files. 而且,这不涉及标题inline css style因此所有样式都直接存储在html中,并确保它们会覆盖css文件中定义的样式。

I found this feature useful for people who are not familiar with web design and development in depth, you can tune up web site just clicking buttons. 我发现此功能对不熟悉Web设计和开发的人员很有用,您只需单击按钮即可调整网站。

But personally for this inline code looks ugly in source code of the page, and to override it I need to inline directly inside tag using style . 但是个人而言,此内联代码在页面的源代码中看起来很丑陋,并且要覆盖它,我需要使用style直接在tag内进行内联。 So I prefer modifying styles directly from css file. 因此,我更喜欢直接从CSS文件中修改样式。

All in all my question is : Is it good practice for using such customizers in production or it is better to structure all styles inside css files without ability to change appearance from customizer. 总的来说,我的问题是:在生产环境中使用这样的定制器是一种好习惯,还是在css文件中构造所有样式而没有从定制器更改外观的更好方法。

PS I am going to use this site for personal purpose, so no one else will modify it. 附言:我将出于个人目的使用此站点,因此没有人会对其进行修改。

Some themes offer a UI to edit background/text colors. 一些主题提供了用于编辑背景/文本颜色的UI。 If this is your case then I would just use that if it's all you need. 如果这是您的情况,那么仅在您需要时使用。

If you're actually writing custom styles then whenever possible I suggest creating a child theme for customizing 3rd party themes. 如果您实际上是在编写自定义样式,那么我建议您尽可能创建一个子主题以自定义第三方主题。 This offers separation from site content (stored in the database) from code and it separates your custom code from the 3rd party's theme code. 这样可以将站点内容(存储在数据库中)与代码分开,并将您的自定义代码与第三者的主题代码分开。 This option requires that you can upload your own themes. 此选项要求您可以上传自己的主题。

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

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