我尝试使用CSS在ZPT页面的Plone。它唯一的工作方式是内联css。在标题中使用样式标签不起作用,也没有尝试使用链接的css文件。
有办法吗?
如果你只想在模板中使用特定的css,那么首先你必须注册你的css资源目录(在浏览器模块中),像这样:
<!-- Register the resource directory for stylesheets -->
<browser:resourceDirectory
name="[YOUR_PLONE_PRODUCT].styles"
directory="styles"
layer=".interfaces.IThemeSpecific"
/>
然后在你的模板中这样使用:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en"
metal:use-macro="here/main_template/macros/master"
i18n:domain="[YOUR_PLONE_PRODUCT]">
<metal:slot fill-slot="css_slot">
<link href="myspecialstyle.css"
rel="stylesheet"
type="text/css"
tal:attributes="href string:${context/portal_url}/++resource++[YOUR_PLONE_PRODUCT].styles/myspecialstyle.css"/>
</metal:slot>
<body>
<metal:main fill-slot="main">
...
这里有一些有用的文档:
- http://collective-docs.readthedocs.org/en/latest/templates_css_and_javascripts/css.html
- http://collective-docs.readthedocs.org/en/latest/templates_css_and_javascripts/template_basics.html
- http://plone.org/documentation/manual/theme-reference/buildingblocks/skin/style-sheets/css