Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LESS CSS IE targeting?

Tags:

css

less

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?

like image 596
panthro Avatar asked Oct 25 '12 16:10

panthro


People also ask

How to target Internet Explorer 8 and below in CSS?

Yes, Internet Explorer is the bane of a web developers life but the browsers prevalence demands we just get on and deal with it. To target Internet Explorer 8 and below in CSS, append “9” to the end of the style you want to apply. e.g.

Is there a CSS3 media query to target only Internet Explorer?

6 Comments on “CSS3 Media Query to target only Internet Explorer (from IE6 to IE11+), Firefox, Chrome, Safari and/or EdgeA set of useful CSS3 media queries to target only specific versions of the various browsers: Internet Explorer, Mozilla Firefox, Google Chrome, Apple Safari and Microsoft Edge” Joshsays: December 10, 2018 at 18:49

What browsers does CSS3 work with?

A set of useful CSS3 media queries to target only specific versions of the various browsers: Internet Explorer, Mozilla Firefox, Google Chrome, Apple Safari and Microsoft Edge. Skip to content Top Menu

Does your client website render on IE6 and IE8?

During one of our latest projects we came across some specific CSS issues with our client website rendering on IE6 and IE8. Yes, Internet Explorer is the bane of a web developers life but the browsers prevalence demands we just get on and deal with it.


3 Answers

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]-->
like image 100
BenM Avatar answered Sep 25 '22 18:09

BenM


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/

like image 43
Scott Simpson Avatar answered Sep 21 '22 18:09

Scott Simpson


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.

like image 27
Joshua Hamilton Avatar answered Sep 23 '22 18:09

Joshua Hamilton