LESS CSS IE targeting?

我是研究僧i 提交于 2019-12-12 11:11:58

问题


What's the best way to target IE7, 8 etc. in LESS?

Is there a method to target them or would I ideally need to load a separate style sheet?


回答1:


As far as I know, LESS doesn't allow you to target specific browsers, only media sizes.

You'll need to do something like:

<!--[if IE]>
<link rel="stylesheet/less" type="text/css" href="ie.less" />
<![endif]-->



回答2:


Using Paul Irish's method of IE targeting allows your IE rules to take full advantage of nesting in your main less file. http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/




回答3:


Using Paul Irish's technique that Scott Simpson linked too, you can very easily include targeted selectors right beside the rest of your CSS. For example:

div {
  display: inline-block;

  .ie-8 & {
    zoom: 1;
    display: inline;
  }
}

Your compiled CSS will then be:

div { display: inline-block; }
.ie-8 div { display: inline; zoom: 1; }

I find this technique preferable to separate stylesheets because it's easier to keep track of your IE-specific CSS.



来源:https://stackoverflow.com/questions/13072967/less-css-ie-targeting

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!