【发布时间】:2016-07-28 11:11:15
【问题描述】:
根据我的情况,我需要将此图像路径 /img/product.png 存储在 razor 变量中,然后我想在 CSS 文件中使用该 razor 变量。下面的css代码在css文件中
.test{
background: url('/img/product.png') no-repeat scroll 0 0 transparent;
}
所以我使用下面这样的代码,但仍然没有运气
.test{
background: url('@Model.LogoUrl') no-repeat scroll 0 0 transparent;
}
我看到了这篇文章http://www.codeproject.com/Articles/171695/Dynamic-CSS-using-Razor-Engine,但我不想按照帖子解决我的问题。所以让我知道如何解决这个问题。谢谢
【问题讨论】:
-
最好在视图本身中使用内部样式表。
-
@ssilas777 对不起,不明白你想说什么......你能不能用一些例子来描述你所说的。谢谢
-
这段代码是在你的 .cshtml 文件还是 .css 文件上?
标签: css asp.net-mvc razor