sass “Mobile first” CSS and getting Sass to help with legacy IE By nicolasgallagher.com Published On :: Mon, 28 Nov 2011 16:00:00 -0800 Taking a “mobile first” approach to web development poses some challenges if you need to provide a “desktop” experience for legacy versions of IE. Using a CSS pre-processor like Sass can help. As of Sass 3.2, there is another way of catering for IE, described by Jake Archibald. One aspect of a “mobile first” approach to development is that your styles are usually gradually built up from a simple base. Each new “layer” of CSS adds presentational adjustments and complexity, via CSS3 Media Queries, to react to and make use of additional viewport space. However, IE 6/7/8 do not support CSS3 Media Queries. If you want to serve IE 6/7/8 something more than just the base CSS, then you need a solution that exposes the “enhancing” CSS to those browsers. Popular existing options An existing option is the use of a CSS3 Media Query polyfill, such as Respond.js. However, there are some drawbacks to this approach (see the project README), such as the introduction of a JavaScript dependency and the XHRing of your style sheets, which may introduce performance or cross-domain security issues. Furthermore, adding support for CSS3 Media Queries is probably not necessary for these legacy browsers. The main concern is exposing the “enhancing” CSS. Another method, which Jeremy Keith has described in his post on Windows mobile media queries, is to use separate CSS files: one basic global file, and an “enhancing” file that is referenced twice in the <head> of the document. The “enhancing” file is referenced once using a media attribute containing a CSS3 Media Query value. This prevents it being downloaded by browsers (such as IE 6/7/8) which do not support CSS3 Media Queries. The same file is then referenced again, this time wrapped in an IE conditional comment (without the use of a CSS3 Media Query value) to hide it from modern browsers. However, this approach becomes somewhat cumbersome, and introduces multiple HTTP requests, if you have multiple breakpoints in your responsive design. Getting Sass to help Sass 3.1 provides some features that help make this second approach more flexible. The general advantages of the Sass-based approach I’ve used are: You have full control over how your style sheets are broken up and reassembled. It removes the performance concerns of having to reference several separate style sheets for each breakpoint in the responsive design, simply to cater for IE 6/7/8. You can easily repeat large chunks of CSS in separate compiled files without introducing maintenance problems. The basic idea is to produce two versions of your compiled CSS from the same core code. One version of your CSS includes CSS3 @media queries and is downloaded by modern browsers. The other version is only downloaded by IE 6/7/8 in a desktop environment and contains no CSS3 @media queries. To do this, you take advantage of the fact that Sass can import and compile separate .scss/.sass files into a single CSS file. This allows you to keep the CSS rules used at any breakpoint completely separate from the @media query that you might want it to be a part of. This is not a CSS3 Media Query polyfill, so one assumption is that IE 6/7/8 users will predominantly be using mid-size screens and should receive styles appropriate to that environment. Therefore, in the example below, I am making a subjective judgement by including all the breakpoint styles up to a width of 960px but withholding those for any breakpoints beyond that. The ie.scss file imports numerous other files, each containing a layer of CSS that builds upon the previous each layer of CSS. No CSS3 @media queries are contained within the files or the ie.scss file. It then compiles to a single CSS file that is designed to be served only to IE 6/7/8. // ie.scss @import "base"; @import "320-up"; @import "480-up"; @import "780-up"; @import "960-up"; The style.scss file imports the code for each breakpoint involved in the design (including any beyond the limit imposed for legacy versions of IE) but nests them within the relevant CSS3 @media query. The compiled version of this file is served to all browsers apart from IE 6/7/8 and IEMobile. // style.scss @import "base"; @media (min-width:320px) { @import "320-up"; } @media (min-width:480px) { @import "480-up"; } @media (min-width:780px) { @import "780-up"; } @media (min-width:960px) { @import "960-up"; } @media (min-width:1100px) { @import "1100-up"; } The resulting CSS files can then be referenced in the HTML. It is important to hide the ie.css file from any IE-based mobile browsers. This ensures that they do not download the CSS meant for desktop versions of IE. <!--[if (gt IE 8) | (IEMobile)]><!--> <link rel="stylesheet" href="/css/style.css"> <!--<![endif]--> <!--[if (lt IE 9) & (!IEMobile)]> <link rel="stylesheet" href="/css/ie.css"> <![endif]--> This Sass-enabled approach works just as well if you need to serve a basic style sheet for mobiles without CSS3 Media Query support, and prevent those devices from downloading the CSS used to adapt the layout to wider viewports. For example, you can avoid importing base.scss into the ie.scss and style.scss files. It can then be referenced separately in the HTML. <link rel="stylesheet" href="/css/base.css"> <link rel="stylesheet" href="/css/style.css" media="(min-width:320px)"> <!--[if (lt IE 9) & (!IEMobile)]> <link rel="stylesheet" href="/css/ie.css"> <![endif]--> You’ll notice that I didn’t wrap the style.css reference in a conditional comment to hide it from legacy versions of IE. It’s not necessary this time because the value of the media attribute is not understood by legacy versions of IE, and the style sheet will not be downloaded. In different circumstances, different combinations of style sheets and media attribute values will be more appropriate. Summary Even if you want to don’t want to use any of the Sass or SCSS syntax, the pre-processor itself can help you to write your CSS in a “mobile first” manner (with multiple breakpoints), provide a “desktop” experience for IE 6/7/8, and avoid some of the performance or maintenance concerns that are sometimes present when juggling the two requirements. I’m relatively new to using Sass, so there may be even better ways to achieve the same result or even to prevent the inclusion of IE-specific CSS unless the file is being compiled into a style sheet that only IE will download. Full Article
sass What great service leaders know and do [electronic resource] : creating breakthroughs in service firms / James L. Heskett, W. Earl Sasser Jr., Leonard A. Schlesinger By prospero.murdoch.edu.au Published On :: Heskett, James L Full Article
sass International humanitarian law: rules, controversies, and solutions to problems arising in warfare / Marco Sassòli, Director, Geneva Academy of International Human Rights and Professor, University of Geneva, Switzerland ; with the assistance of Patri By library.mit.edu Published On :: Sun, 23 Feb 2020 09:36:00 EST Dewey Library - KZ6471.S27 2019 Full Article
sass Director of the INFN Gran Sasso National Laboratory – Assergi (L’Aquila) Italy: Istituto Nazionale di Fisica Nucleare (INFN) By brightrecruits.com Published On :: Thu, 23 Apr 2020 00:00:00 +0100 €Attractive: Istituto Nazionale di Fisica Nucleare (INFN)For more latest jobs and jobs in Italy visit brightrecruits.com Full Article Italy
sass Medical biotechnology : achievements, prospects and perceptions / Albert Sasson By prospero.murdoch.edu.au Published On :: Sasson, Albert Full Article
sass Change SASS variable depending of subdomain By css-tricks.com Published On :: Fri, 24 Jan 2020 12:35:57 +0000 Hi, I have a WordPress multi site (site.com / subdomain1.site.com / subdomain2.site.com), and I want to change the primary color depending of the subdomain. I have assigned a class to the body depending of the subdomain. I tried this : .subdomain-1 $primary : #5E1B3C .subdomain-2 $primary: #BE0050 But it doesn’t work. Have you got an idea of how to do this ? Thank you ! Full Article
sass Assassin aimed at president-elect in Miami By digital.lib.usf.edu Published On :: Mon, 20 Jan 2014 12:42:17 -0400 Full Article
sass Udell Lodge, Homosassa, Fla By digital.lib.usf.edu Published On :: Mon, 03 Feb 2014 18:17:38 -0400 Full Article
sass The Atlanta Club House, Homosassa, Fla By digital.lib.usf.edu Published On :: Mon, 03 Feb 2014 18:18:11 -0400 Full Article
sass Udell Lodge, Homosassa, Fla By digital.lib.usf.edu Published On :: Mon, 03 Feb 2014 18:18:22 -0400 Full Article
sass A day's catch at Homosassa Springs Hotel By digital.lib.usf.edu Published On :: Mon, 03 Feb 2014 18:18:39 -0400 Full Article
sass Homosassa Springs Hotel By digital.lib.usf.edu Published On :: Mon, 03 Feb 2014 18:18:42 -0400 Full Article
sass B.F. Dutton residence, Homosassa, Fla By digital.lib.usf.edu Published On :: Mon, 03 Feb 2014 18:19:12 -0400 Full Article
sass Homosassa Springs Gator Lagoon By digital.lib.usf.edu Published On :: Mon, 03 Feb 2014 18:19:19 -0400 Full Article
sass Truly "more fun than a barrel of monkeys" at Homosassa Springs By digital.lib.usf.edu Published On :: Mon, 03 Feb 2014 18:19:27 -0400 Full Article
sass Thonotosassa Boulevard, Golden Hills, Uptown Tampa By digital.lib.usf.edu Published On :: Mon, 10 Feb 2014 10:10:52 -0400 Full Article
sass Spectre of Thunderbolt Cavern, or, Tricked by midnight assassins By digital.lib.usf.edu Published On :: Fri, 14 Feb 2014 11:31:22 -0400 Full Article
sass Tampa mayor Nick Nuccio and a group of people at Lake Thonotosassa By digital.lib.usf.edu Published On :: Sun, 16 Feb 2014 09:02:15 -0400 Full Article
sass The Ring Master float from Lake Thonotosassa School during the Children's Gasparilla Parade By digital.lib.usf.edu Published On :: Sun, 16 Feb 2014 10:46:17 -0400 Full Article
sass Patrick V. Garland collection on the reassessment of the Robert F. Kennedy Assassination By digital.lib.usf.edu Published On :: Tue, 18 Feb 2014 19:25:32 -0400 Full Article
sass Kathleen Cunningham research collection on the Assassination of President John F. Kennedy By digital.lib.usf.edu Published On :: Tue, 18 Feb 2014 19:26:06 -0400 Full Article
sass Geologic controls on the holocene evolution of an open-marine marsh system fronting a shallow-water embayment, Waccasassa Bay, West-Central Florida By digital.lib.usf.edu Published On :: Tue, 03 Jun 2014 12:47:33 -0400 Full Article
sass Marriage record of Lightsey, Charles and Sasser, Fannie By digital.lib.usf.edu Published On :: Wed, 04 Jun 2014 10:55:39 -0400 Full Article
sass Among Russian Nihilists, or, The great assassination plot By digital.lib.usf.edu Published On :: Thu, 14 Jan 2016 14:35:10 -0400 Full Article
sass The detective road-agent, or, The miners of Sassafras City By digital.lib.usf.edu Published On :: Thu, 18 Feb 2016 14:13:14 -0400 Full Article
sass Fate of sulfide in the Frasassi cave system and implications for sulfuric acid speleogenesis By digital.lib.usf.edu Published On :: Wed, 22 Mar 2017 13:03:09 -0400 Full Article
sass Gypsum deposits in the Frasassi Caves, Central Italy By digital.lib.usf.edu Published On :: Mon, 06 Apr 2020 12:40:44 -0400 Full Article
sass Fate of sulfide in the Frasassi cave system and implications for sulfuric acid speleogenesis By digital.lib.usf.edu Published On :: Mon, 06 Apr 2020 14:36:56 -0400 Full Article
sass Pune: Sassoon hires 36 doctors from private hospitals for COVID-19 treatment By indianexpress.com Published On :: Tue, 28 Apr 2020 19:34:32 +0000 Full Article Cities Pune
sass Pune: Sassoon Hospital gets ICMR nod for plasma therapy By indianexpress.com Published On :: Sat, 02 May 2020 23:58:23 +0000 Full Article Cities Pune
sass Sassy restaurateur and pastry chef Rachel Goenka ramps up the oomph factor of Indian sweets By indianexpress.com Published On :: Sat, 02 Nov 2019 19:01:59 +0000 Full Article Books Lifestyle
sass Serie A’s Sassuolo say players can start training from Monday By indianexpress.com Published On :: Sun, 03 May 2020 03:53:56 +0000 Full Article Football Sports
sass Chandigarh stalking case: Ready to fight character assassination aimed at my daughter, says father By indianexpress.com Published On :: Mon, 07 Aug 2017 21:47:41 +0000 Full Article Crime India