如何在Orchard模块中包含css样式表? [英] How to include a css stylesheet in Orchard module?

查看:131
本文介绍了如何在Orchard模块中包含css样式表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Orchard工作一个模块,我只想知道如何包含一个css文件。



我做了以下没有结果: / p>

在我的模块的根目录中添加了一个Styles文件夹,包括一个样式表和一个Web.config文件,如这个问题。



我看到,但这不是我要找的。

编辑:



好的,解决方案:



当我开始在Orchard通过在 Orchard.Web / Modules 文件夹中创建一个新项目创建了一个新模块,但当我阅读在这里,我的视图/ Web.config 文件必须包括一些果园基础的东西,我没有,因为我没有创建模块使用codegen。我现在通过替换我的 Web.config 文件为 Web.config 文件从另一个Orchard模块,现在它修复了



下一次我将使用codegen创建一个新模块。



感谢endorphin帮助我!

解决方案

如果要在视图中包括样式表,则需要在视图顶部指定。其中样式表的名称是样式文件夹中的.css文件的文件名。



因此,在您的视图的.cshtml文件中。

  @ {
Style.Include(your-stylesheet.css)。AtHead();
}



我使用了 AtHead(),但是还有其他方法可以将您的样式表包含在不同的位置(例如 AtFoot()



如果您的样式表依赖于其他样式表,您可以通过创建资源清单来做一些更有趣的事情,详情请参见 http: //stackoverflow.com/a/6500121/580101


I am working on a module for Orchard, and I just want to know how to include a css file.

I have done the following with no result:

Added a folder "Styles" to the root of my module and included a stylesheet and a Web.config file like in this question.

And I have seen this but that's not what I am looking for.

EDIT:

Ok, solution:

When I started working on Orchard I created a new module by just creating a new project in Orchard.Web/Modules folder, but as I read here, my Views/Web.config file has to include some orchard base things what mine didn't because I did not create the module using codegen. I fixed it now by replacing my Web.config file for a Web.config file from another Orchard module, now it works.

Next time I will use codegen to create a new module.

Thanks to endorphin for helping me!

解决方案

If you want to include your stylesheet in a view, you need to specify this at the top of your view. Where the name of your stylesheet is the filename of the .css file in the Styles folder.

So in your .cshtml file for your view..

@{
  Style.Include("your-stylesheet.css").AtHead();
}

I have used AtHead() in the past, but there are other methods to include your stylesheet in different locations (such as AtFoot())

If your stylesheet depends on other stylesheets you can do something a little more interesting by creating a Resource Manifest which is detailed here http://stackoverflow.com/a/6500121/580101

这篇关于如何在Orchard模块中包含css样式表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆