【问题标题】:How to include css stylesheet to Mako template如何将 css 样式表包含到 Mako 模板中
【发布时间】:2013-08-25 16:56:12
【问题描述】:

我正在为 python 使用 Mako 模板引擎。我想在我的文档中添加 css 样式表,但我不知道该怎么做。有什么帮助吗?

【问题讨论】:

    标签: python mod-wsgi mako


    【解决方案1】:
    <head>
    <link rel="stylesheet" type="text/css" href="mystyle.css">
    </head>
    

    确保 href 指向您的 CSS 文件(并且在正确的目录中)

    直接取自W3Schools。 Mako 模板没有什么特别之处,它们只是帮助您构建动态 html。

    【讨论】:

    • 不...它不起作用,因为我正在使用 mod_wsgi。还有其他提示吗?
    • 这是一个不同的问题,但据我所知(我不使用 Python 或 Apache),您需要将 Apache 配置为提供静态资产(除上述之外)。查看起点stackoverflow.com/questions/2078160/…
    【解决方案2】:

    Mako docs for include

    <%include file="some_css_you_want_to_include.css" />
    

    【讨论】:

    • mako.exceptions.TemplateLookupException: Template 'template.txt' has no TemplateLookup associated
    猜你喜欢
    • 2020-02-17
    • 2011-03-23
    • 2011-12-24
    • 2011-06-16
    • 2017-08-28
    • 1970-01-01
    • 1970-01-01
    • 2013-10-18
    • 2012-04-22
    相关资源
    最近更新 更多