We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
这并不是真正的编译器技巧,但如果您想使用条件注释而不必编译单独的每个浏览器样式表,您可以简单地使用 HTML 条件注释来注入样式挂钩。例如:
现在您可以将要应用于 IE<=6 和 IE<=7 的规则定位在与其余规则相同的样式表中:
这在 IMO 中比
* html
hack 稍微干净一些,这是最后一个可接受的 CSS hack。 (“星号 hack”和“下划线 hack”是无效的 CSS:避免。)It's not really a compiler trick, but if you want to use conditional comments without having to compile separate per-browser stylesheets, you can simply use HTML conditional comments to inject a styling hook. For example:
Now you can target rules you want to apply to IE<=6 and IE<=7 in the same stylesheet as the rest of the rules:
This is IMO marginally cleaner than the
* html
hack, which is the last acceptable CSS hack. (The “star hack” and “underscore hack” are invalid CSS: avoid.)您可以有条件地包含为 IE6/7/whathaveyou 生成的 CSS 表:
此外,如果您担心将 IE 修复/黑客与大量 SASS/CSS 混合在一起,您可以将它们分解为自己的部分:
上述内容将包括当前 SASS 文档中该特定版本 IE 的所有规则。有关部分的文档可以在这里找到:SASS 部分
You can just conditionally include a generated CSS sheet for IE6/7/whathaveyou:
Also, if you're worried about mixing in the IE fixes/hacks with the bulk of your SASS/CSS, you can break them up into their own partials:
The above would include all the rules for that particular version of IE in the current SASS document. Documentation on partials can be found here: SASS Partials
事实并非如此:虽然“underscore hack”是无效的,但“* html”和“*+html” hack是完全有效的CSS。 自己检查一下。 ;)
~
至于上面的问题,目前我不知道有任何编译器能够做到这一点,我仍然更喜欢使用 start hack (IE6-7) 并将所有内容保存在一个文件中。更易于维护。
Not really: while the "underscore hack" is invalid, the "* html" and "*+html" hacks are perfectly valid CSS. Check it out yourself. ;)
~
As for the question above, for now I'm not aware of any compiler able to do that, I still prefer to user the start hack (IE6-7) and keep everything in one file. More maintainable.