How to write a media query in CSS? - css

I need to write different styles in following cases
Device width greater than device height
/* Landscape */
#media screen and (orientation:landscape) {
.bg img {
height: auto;
width: 100%;
}
}
Device height greater than device width
/* Portrait */
#media screen and (orientation:portrait) {
.bg img {
height: 100%;
width: auto;
}
}
Orientation doesn't work perfectly in some stages on resizing the browser.
How to write correct CSS?
Is it possible to do so with CSS?
EDIT :
I am attaching image how it looks on resizing the browser

You have access to the browser's aspect ratio with these media query features: aspect-ratio | min-aspect-ratio | max-aspect-ratio. For more info, check out CSS media queries on MDN.
Portrait has an aspect ratio greater than 1:1 and landscape is less. To verify, I made a JSFiddle that changes color when you switch from "landscape" to "portrait".
Try this:
/* Landscape (i.e. wide viewport) */
#media screen and (min-aspect-ratio: 1/1) {
.bg img {
height: auto;
width: 100%;
}
}
/* Portrait (i.e. narrow viewport) */
#media screen and (max-aspect-ratio: 1/1) {
.bg img {
height: 100%;
width: auto;
}
}
Update: The image is part of the flow of the document, and won't fill the viewport unless the body also fills the viewport with body {height: 100%;}, as in this JSFiddle.
Try img {position: absolute;} to pull the image out of the flow, so it's dimensions aren't constrained by the body's size. See JSFiddle.

The problem that you were having was that you were relying on the text "orientation:landscape" which is not recognised by browsers. Use the code below which check the height and width of a device to calculate its orientation. Credit to css-tricks.com who can really help with media queries, here is an example of the most common uses of media queries.
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
#media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
#media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- */
#media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
#media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
#media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}
Source http://css-tricks.com/snippets/css/media-queries-for-standard-devices/

I have a similar need but I was using:
<link rel='stylesheet' media='screen and (max-aspect-ratio: 4/3)' href='css/tall.css' />
<link rel='stylesheet' media='screen and (min-aspect-ratio: 4/3)' href='css/wide.css' />
The only problem was, when I hit 768 x 1024 it displayed correctly, but when I went to 1024 x 768, I got a blank page. I was using a simple css display assignment like:
display:none;
to turn the div on or off, which works but my question is how can you make a continuos flow without that break? at 1024 x 768
I am using this right now:
<link rel='stylesheet' media='screen and (orientation:portrait)' href='css/tall.css' />
<link rel='stylesheet' media='screen and (orientation:landscape)' href='css/wide.css' />
I would like to use max-aspect-ratio and what not, because that gives me more control over when change happens. I mean I can't put 1.333 ratio and 1.334 bummer...
--NEW UPDATE
<!-- tall -->
<link rel='stylesheet' media='screen and (max-aspect-ratio:4/3) and (min-width:0px) and (max-width:1023px)' href='css/tall.css'/>
<!-- tall -->
<link rel='stylesheet' media='screen and (max-aspect-ratio:4/3) and (min-width:1025px) and (max-width:9999px)' href='css/tall.css'/>
<!-- wide -->
<link rel='stylesheet' media='screen and (min-aspect-ratio:4/3)' href='css/wide.css'/>
I guess I fixed my problem by doing the above code, which is disappointing. But it works so far, I am just going to have to test for almost every screen to make sure higher resolutions that are EXACTLY 4:3 by the Query "terms" still show. I tried 2048 x 1536 iPad3 Retina and that shows up, don't know why 1024 x 768 fails... but is working with the fix above.
----UPDATE 2 (I hate to be a pain but)
This seems to be the cleanest solution for aspect-ratio:4/3 :
<!-- tall 1.33301 -->
<link rel='stylesheet' media='screen and (max-aspect-ratio:4095/3072)' href='css/tall.css'/>
<!-- wide 1.33333 -->
<link rel='stylesheet' media='screen and (min-aspect-ratio:4096/3072)' href='css/wide.css'/>

Related

CSS links not working for responsive design

So I'm creating a responsive design website depending on the users device, however when viewing the site on an iPhone 5C the css link for the smartphone version css/smartphone/header.css doesn't work, and neither does the tablet css/tablet/header.css file. It just shows the desktop version on the mobile phone (which I don't want). But when I view the site on the Google Developer 'Dimensions' extension, which allows you to mimic a mobile device (in this case the iPhone 5), the css links work as intended.
Can someone tell me what is wrong with my css links which causes them to not work on the iPhone 5? Thank you
<link type='text/css' rel='stylesheet' media='screen and (min-width: 1024px)' href='css/desktop/header.css' />
<link type='text/css' rel='stylesheet' media='screen and (min-width: 200px) and (max-width: 767px)' href='css/smartphone/header.css' />
<link type='text/css' rel='stylesheet' media='screen and (min-width: 768px) and (max-width: 1023px)' href='css/tablet/header.css' />
Try: <meta name="viewport" content="width=device-width, initial-scale=1.0" />. For more info, see this article on MDN:
https://developer.mozilla.org/en/docs/Mozilla/Mobile/Viewport_meta_tag.
Try to use some solid device specific media queries when building responsive websites.
In your case the media queries are not the right ones for iphone.
For instance you could use these ones as a starting point and then if needed you can search for other resources online.
/*
* From css-tricks.com
* http://css-tricks.com/snippets/css/media-queries-for-standard-devices/
*/
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
#media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
#media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- */
#media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
#media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
#media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}
Here you can find a more extensive list with specific devices: http://nmsdvid.com/snippets/

Re-order divs for responsive design

I am working on a responsive design and I would like to re-order some divs at certain breakpoints. I am not sure if this is even possible, but here it goes.
Here is a rough fiddle showing the current layout: http://jsfiddle.net/Ubjmc/ above a certain breakpoint. As you can see the order (of the divs) go - one, two and then three.
And this is how I want it to look after my breakpoint: http://jsfiddle.net/AfT4D/ The order of the divs for this one is - one, three and then two.
I am not sure this is possible to do with straight css. What I have been doing so far is making a 4th element that hides above the breakpoint and shows after the breakpoint and then hiding the element it replaces at that breakpoint (hopefully that makes sense).
Is that method the only reliable css-only way of doing what I'd like (that isn't extremely convoluted)?
Edit - I already have my breakpoint set and am using media queries. The second fiddle in my example is how I want the first to look, in the order of the first (or I want to find out if that is possible).
<div class="wrap">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
</div>
The question is if I have my order like shown in the code above, if there any possible way to get it to look like this: http://jsfiddle.net/AfT4D/, without editing the order of the divs?
You have already a property in CSS called order, and it is available in flex display.
Set the container to
.wrap {
display: flex;
flex-wrap: wrap;
}
Then you can set the order 3 to two
.two {
order: 3;
}
And that is it !
demo
Support isn't very high, but it is coming (Firefox should release flex-wrap support this month)
You would have to use media queries, I think it would be better to do it in the HTML instead of css such as
<link href="smartPhone.css" type="text/css" rel="stylesheet" media="screen and(min device-width : 320px) and (max-device-width : 480px)>
<link href="tablets.css" type="text/css" rel="stylesheet" media="screen and(min device-width : 481px) and (max-device-width : 1024px)>
<link href="computer.css" type="text/css" rel="stylesheet" media="screen and(min device-width : 1025px)>
You can find out more here http://www.htmlgoodies.com/html5/tutorials/an-introduction-to-css3-media-queries.html#fbid=T7Km4lhd7oK
JSFiddle Example: http://jsfiddle.net/Ubjmc/1/
You have to put .three below .one
<div class="wrap">
<div class="one"></div>
<div class="three"></div>
<div class="two"></div>
</div>
And edit your CSS ( ??? = Screen Width ):
#media only screen and (max-width: ???px) {
.one,.three{width:50% !important;}
.two{width:100% !important;}
.two{clear:both;}
}
.three {
float: right;
/* ... */
}
You'll want to investigate media queries. This way you can customize the layout at different widths.
Here's a starter template:
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
#media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
#media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- */
#media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
#media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
#media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}
If you're having trouble getting the desired results, you can also try jQuery's insertAfter and insertBefore and build the columns on the fly based on screen size.

#Media min-width & max-width

I have this #media setup:
HTML:
<head>
<meta name="viewport" content="width=device-width, user-scalable=no" />
</head>
CSS:
#media screen and (min-width: 769px) {
/* STYLES HERE */
}
#media screen and (min-device-width: 481px) and (max-device-width: 768px) {
/* STYLES HERE */
}
#media only screen and (max-device-width: 480px) {
/* STYLES HERE */
}
With this setup it works on the iPhone but it does not work in the browser.
Is it because I already have device in the meta, and maybe have max-width:480px instead?
I've found the best method is to write your default CSS for the older browsers, as older browsers (including IE 5.5, 6, 7 and 8) can't read #media. When I use #media, I use it like this:
<style type="text/css">
/* default styles here for older browsers.
I tend to go for a 600px - 960px width max but using percentages
*/
#media only screen and (min-width: 960px) {
/* styles for browsers larger than 960px; */
}
#media only screen and (min-width: 1440px) {
/* styles for browsers larger than 1440px; */
}
#media only screen and (min-width: 2000px) {
/* for sumo sized (mac) screens */
}
#media only screen and (max-device-width: 480px) {
/* styles for mobile browsers smaller than 480px; (iPhone) */
}
#media only screen and (device-width: 768px) {
/* default iPad screens */
}
/* different techniques for iPad screening */
#media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait) {
/* For portrait layouts only */
}
#media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape) {
/* For landscape layouts only */
}
</style>
But you can do whatever you like with your #media. This is just an example of what I've found best for me when building styles for all browsers.
iPad CSS specifications.
Also! If you're looking for printability you can use #media print{}.
The underlying issue is using max-device-width vs plain old max-width.
Using the "device" keyword targets physical dimension of the screen, not the width of the browser window.
For example:
#media only screen and (max-device-width: 480px) {
/* STYLES HERE for DEVICES with physical max-screen width of 480px */
}
Versus
#media only screen and (max-width: 480px) {
/* STYLES HERE for BROWSER WINDOWS with a max-width of 480px.
This will work on desktops when the window is narrowed. */
}
If website on small devices behavior like desktop screen then you have to put this meta tag into header before
<meta name="viewport" content="width=device-width, initial-scale=1">
For media queries you can set this as
this will cover your all mobile/cellphone widths
#media only screen and (min-width: 200px) and (max-width: 767px) {
//Put your CSS here for 200px to 767px width devices (cover all width between 200px to 767px //
}
For iPad and iPad pro you have to use
#media only screen and (min-width: 768px) and (max-width: 1024px) {
//Put your CSS here for 768px to 1024px width devices(covers all width between 768px to 1024px //
}
If you want to add css for Landscape mode you can add this
and (orientation : landscape)
#media only screen and (min-width: 200px) and (max-width: 767px) and (orientation : portrait) {
//Put your CSS here for 200px to 767px width devices (cover all mobile portrait width //
}
The correct value for the content attribute should include initial-scale instead:
<meta name="viewport" content="width=device-width, initial-scale=1">
^^^^^^^^^^^^^^^
If you want to include both min and max width for responsiveness in the browser, then you can use the following:
#media (min-width: 768px) and (max-width: 992px){...}
#media (min-width: 480px) and (max-width: 767px) {...}
for some iPhone you have to put your viewport like this
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, shrink-to-fit=no, user-scalable=0" />

Which are the most important media queries to use in creating mobile responsive design?

There are a lot different media queries for mobile screen sizes. It can be overwhelming to accomodate all of them when designing a responsive mobile site. Which are the most important ones to use when designing for mobile? I found this article that does a pretty good job of outlining the available media queries: http://css-tricks.com/snippets/css/media-queries-for-standard-devices/.
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
#media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
#media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- */
#media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
#media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
#media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}
I'd recommend taking after Twitter's Bootstrap with just these four media queries:
/* Landscape phones and down */
#media (max-width: 480px) { ... }
/* Landscape phone to portrait tablet */
#media (max-width: 767px) { ... }
/* Portrait tablet to landscape and desktop */
#media (min-width: 768px) and (max-width: 979px) { ... }
/* Large desktop */
#media (min-width: 1200px) { ... }
Edit: The original answer (above) was taken from Bootstrap version 2. Bootstrap has since changed their media queries in version 3. Notice that is there is no explicit query for devices smaller than 768px. This practice is sometimes called mobile-first. Everything outside of any media query is applied to all devices. Everything inside a media query block extends and overrides what is available globally as well as styles for all smaller devices. Think of it as progressive enhancement for responsive design.
/* Extra small devices (phones, less than 768px) */
/* No media query since this is the default in Bootstrap */
/* Small devices (tablets, 768px and up) */
#media (min-width: 768px) { ... }
/* Medium devices (desktops, 992px and up) */
#media (min-width: 992px) { ... }
/* Large devices (large desktops, 1200px and up) */
#media (min-width: 1200px) { ... }
Check it out on Bootstrap 3's docs.
Design in percentages and initially optimized for a 15"+ screen.
Review what components you want to see on a phone - just keep essential content and remove elements that don't work or clutter the small screen. These styles can be contained within #media (max-width: 480px) { ... }
As things move to 10" or less, redesign your buttons and interactive components for fingers rather than mouse. #media (max-width: 767px) { ... }
Shrink the width of your browser. When things don't look so good, get in to the console and figure out what styles can be changed or items that need to be redesigned or removed. Mark what screen width they occur at and create a media query.
At the end, review your media queries to see if some of them can be grouped together (ie if you have one at 750 and 767 pixels width, you might just as well with combining them in the 767).
If you are comfortable w jQuery you can add
$(window).resize(function(){
console.log($(window).width());
});
to get the current screen size. Add a few extra pixels for good measure.
The first Twitter Bootstrap code referenced by #cjlarose assumes that you've built your main CSS for a display that is between 980px and 1200px wide, so you're essentially starting with the desktop design and adapting all of the others from it.
I'm glad to see Twitter has changed to "mobile first" in Bootstrap 3. It's one of the most popular approaches to media queries, and the way I prefer to do it. You start from the smallest size rather than from the desktop out.
Note that your particular site may need different queries than what are listed there or on any other list. You should add queries as your content demands, not based on any set template.
Here are some media queries I've found most useful. These are just some examples:
/* Start with baseline CSS, for the smallest browsers.
Sometimes I put this into a separate css file and load it first.
These are the "mobile first" styles. */
...
/* Then progressively add bigger sizes from small to large */
/* Smartphones start somewhere around here */
#media (min-width: 300px) {
}
/* You might do landscape phones here if your content seems to need it */
#media (min-width: 450px) {
}
/* Starting into tablets somewhere in here */
#media (min-width: 600px) {
}
/* Perhaps bigger tablets */
#media (min-width: 750px) {
}
/* Desktop screen or landscape tablet */
#media (min-width: 900px) {
}
/* A bit bigger if you need some adjustments around here */
#media (min-width: 1100px) {
}
/* Widescreens */
#media (min-width: 1500px) {
}
The most important thing is that you may not need all of these, or you might want to change the numbers depending on what your content looks like. I don't think there are any really hard rules about how many or where to put your breakpoints. I'm doing a site right now that happens to only need one breakpoint because the content is pretty simple, but I've also done sites that look more like the code above.
I didn't include the retina display code. That's useful if you're switching out normal-resolution images for high-resolution images on hi-res displays, but otherwise it's not really that useful.

What are good resolution values to use with media queries?

Recently I've been playing around with CSS Media Queries because it's a great way to make my website adapt to various screen sizes. I am planning to implement them into the live version.
My question is: Are there any recommended resolution values at which the layout changes?
See this article for a template '320 and Up' - by Andy Clarke, it's used by many developers and designers: http://www.stuffandnonsense.co.uk/blog/about/this_is_the_new_320_and_up
If you scroll down to the media queries section you'll see they use five CSS3 Media Query increments (480, 600, 768, 992 and 1382px). Typically I stick to just 4 (480, 600, 768, 1024).
To explain the ranges:
min-width: 480px: Will target mobile devices in landscape mode and up
min-width: 600px: Targets tablets in portrait mode and up
min-width: 768px: Targets tablets in landscape mode and up
min-width: 1024px: Targets the desktop view
And typically I will have my mobile portrait view CSS at the very beginning (hence the term "320 and up").
I would just like to add to Suvi's answer.
Adaptive Design applies media queries to targeted resolutions however with Responsive Design you are free to add the breakpoints wherever you feel is necessary.
There is no rule as to how many breakpoints a page should have, but one should be added wherever the layout breaks. The aim is to make sure the design and content flows nicely regardless of the width of the viewport.
I think this post provides a good overview:
http://www.williamwalker.me/blog/an-introduction-to-responsive-design.html
Try this one with retina display
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
#media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
#media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- */
#media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
#media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
#media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}
Hope you are fine
I wrote this less solution:
/* screens range */
#screen-s-max: 20em; /* 320px */
#screen-min: 20.063em; /* 321px */
#screen-max: 40em; /* 640px */
#screen-m-min: 40.063em; /* 641px */
#screen-m-max: 64em; /* 1024px */
#screen-l-min: 64.063em; /* 1025px */
#screen-l-max: 90em; /* 1440px */
#screen-xl-min: 90.063em; /* 1441px */
#screen-xl-max: 120em; /* 1920px */
#screen-xxl-min: 120.063em; /* 1921px */
/*
0----- smallmobile -----320----- mobile -----640----- tablet -----1024----- notebook -----1440----- desktop -----1920----- wide
*/
#onlyScreen: ~"only screen";
#smallmobile: ~"(max-width: #{screen-s-max})";
#mobile: ~"(min-width: #{screen-s-max}) and (max-width: #{screen-max})";
#tablet: ~"(min-width: #{screen-m-min}) and (max-width: #{screen-m-max})";
#notebook: ~"(min-width: #{screen-l-min}) and (max-width: #{screen-l-max})";
#desktop: ~"(min-width: #{screen-xl-min}) and (max-width: #{screen-xl-max})";
#wide: ~"(min-width: #{screen-xxl-min})";
#portrait: ~"(orientation:portrait)";
#landscape: ~"(orientation:landscape)";
#highdensity: ~"only screen and (-webkit-min-device-pixel-ratio: 1.5)",
~"only screen and (min--moz-device-pixel-ratio: 1.5)",
~"only screen and (-o-min-device-pixel-ratio: 3/2)",
~"only screen and (min-device-pixel-ratio: 1.5)";
#mobile-and-more: ~"(min-width: #{screen-min})";
#tablet-and-more: ~"(min-width: #{screen-m-min})";
#notebook-and-more: ~"(min-width: #{screen-l-min})";
#desktop-and-more: ~"(min-width: #{screen-xl-min})";
/*
syntax example
#media #onlyScreen and #tablet and #portrait , #notebook and #landscape, #mobile and #landscape{
body{
opacity: 0.8;
}
}
*/
As shown in syntax example you can combine all these less variables and obtain complex media query. Use "and" for AND logic operator and comma for OR. You can combine different screen resolutions, device orientation (landscape/portrait) and retina or not devices.
This code is also easy configurable cause you can edit/add/remove screens range values to manage different screen resolutions.

Resources