我可以将自定义 CSS 样式应用于特定帖子吗?
如果我没记错的话,帖子的 css
属性与 post
和 post-content
类相关,所以如果我重写它们的一些属性,将适用于我网站上的所有帖子。
我想仅将一些 css
属性应用于特定帖子,我该怎么做?
The css
properties of a post are related to post
and post-content
classes if I am not wrong so if I override some of their properties this will apply to all posts in my site.
I would like to apply apply some css
properties only to a particular post, how can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有两种方法:
解决方案 1:额外的 css 文件
最好的方法是使用 页面资源。您可以浏览 页面包 中的文件并查找 CSS 文件。然后,您应该使用以下方法将 CSS 文件添加到您的 head/content 中:
解决方案 2:body 类
一种更简单(但更混乱)的方法是向您的 body 添加一个类。看起来像这样:
这将使用页面的 slug 添加一个类到主体中。这样,您可以通过向主样式表添加规则来应用特定于页面的样式。
Here are two ways to do it:
Solution 1: extra css file
The nicest way to do this is with page resources. You can walk over the files in the page bundle and look for a CSS file. You should then add the CSS file to your head/content using:
Solution 2: body class
A simpler (but messier) way is to add a class to your body. This looks like this:
This will add a class to the body with the slug of your page. This way you can apply page specific styling, by adding rules to your main stylesheet.