0

我的编译器文件是这样的

cd /d %~dp0
java -jar ../../../../file/css-compiler.jar --pretty-print ^
--allowed-unrecognized-property -khtml-opacity ^
    ../source/abc.gss ^
    > ../abc.css
pause

当我添加以下行以检测 IE 编译器给出错误时

<!--[if IE]>
.vidizmo-widget .result-summary {width:0px;}
<![endif]-->

然后我写下一行

@if (BROWSER_IE) {
.vidizmo-widget .result-summary {width:0px;}
}@else{
.vidizmo-widget .result-summary {width:30%;}
}

它不会产生错误,但我没有发现对 IE 有任何影响。

如何使用 google css 编译器检测浏览器?

4

1 回答 1

1

Yes, your second approach is correct

@if (BROWSER_IE) {
  .vidizmo-widget .result-summary {width:0px;}
}@else{
  .vidizmo-widget .result-summary {width:30%;}
}

Then you need to compile the closure template (gss) for every browser (more precisely: for every flag) you defined:

java -jar closure-stylesheets.jar example.gss > example.css
java -jar closure-stylesheets.jar --define BROWSER_IE example.gss > example.ie.css
java -jar closure-stylesheets.jar --define BROWSER_FF2 example.gss > example.ff2.css
…

Then, you need to load the appropriate css; and this is easy:

  • either with JavScript
  • or with a server-side serving based on User-Agent
于 2014-06-03T21:10:05.480 回答