asp.net-mvc 如何在 razor 文件中指定 CSS @media?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6873624/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 01:22:32 来源:igfitidea点击:
How can I specify CSS @media within a razor file?
提问by Janese
I have the following:
我有以下几点:
@if (Model.PageMeta.Sidebar == PageMetaSidebar.Small) { Html.RenderPartial("_SmallSidebar"); }
and in my include file:
在我的包含文件中:
<style "text/css">
#sbr { width: 193px; }
#lft { left: 205px; top: 85px; right: 5px; bottom: 30px; }
#top { left: 215px; top: 85px; right: 15px; }
#btm { left: 215px; right: 15px; bottom: 30px; }
#mdl { left: 215px; top: 85px; right: 15px; bottom: 30px; }
@media print {
div#lft {left:10px; right: 10px; top: 0px;}
div#top {left:20px; right: 20px; top: 0px;}
div#btm {left:20px; right: 20px; }
div#mdl {left:20px; right: 20px; top: 0px;}
}
}
</style>
However this gives me a compile type error:
但是,这给了我一个编译类型错误:
_SmallSidebar.cshtml(7): error CS0103: The name 'media' does not exist in the current context
Does anyone out there know how I could fix this so it accepts that @media is not something that needs to be evaluated?
有没有人知道我如何解决这个问题,所以它接受@media 不是需要评估的东西?
回答by Buildstarted
You can use @@which razor ignores and prints one @.
您可以使用@@which razor 忽略并打印 one @。

