@media媒体查询和ASP.NET MVC剃刀语法冲突 [英] @media media query and ASP.NET MVC razor syntax clash

查看:2141
本文介绍了@media媒体查询和ASP.NET MVC剃刀语法冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在ASP.NET MVC使用的Razor视图引擎运行一个大型网站。

I've got a large site that runs in ASP.NET MVC using the Razor view engine.

我有一个基础的样式表,它包含所有整个网站通用的造型。有时,但是,我有特定的页面风格这在<头方式> 页面 - 这通常是一个或两行

I have a base stylesheet which contains all of the generic styling for the whole site. On occasion, however, I have page specific styles which in the <head> of the page - usually this is one or 2 lines.

我特别不喜欢把CSS在&LT; HEAD&GT; 因为它不是严格分离的关注,但对于一两行,那真的是具体到该网页上,我preFER没有附加其他文件,并添加到带宽。

I don't particularly like putting the CSS in <head> as its not strictly separation of concerns, but for one or two lines, that really is specific to that page, I prefer not have to attach another file and add to the bandwidth.

我有,虽然在这里我想提出一个页面特定媒体查询到一个实例&LT; HEAD&GT; ,但由于媒体的查询使用@符号和括号{}这是剃刀语法冲突:

I've got an instance though where I would like to put a page specific media query into the <head>, but because a media query uses the @ symbol and brackets {} it's clashing with the razor syntax:

@section cphPageHead{
     <style>
        /* PAGE SPECIFIC CSS */
        ...

        @media only screen and (max-width : 960px) <-- the @ symbol here is clashing!
            {
               ... }
            } 
    </style>
}  

有没有一种办法可以解决这个问题?

Is there a way I can get around this?

推荐答案

使用双@@符号。这将难逃@符号和正确呈现@media在客户端

use double @@ symbols. That will escape @ symbol and render @media correctly on client side

这篇关于@media媒体查询和ASP.NET MVC剃刀语法冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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