Fancy Media Queries with some LESS Magic

Here is what I’ve done in my projects: @desktop: ~”only screen and (min-width: 960px) and (max-width: 1199px)”; @tablet: ~”only screen and (min-width: 720px) and (max-width: 959px)”; @media @desktop { footer { width: 940px; } } @media @tablet { footer { width: 768px; } } This allows you to only define your media queries once and … Read more

Max-Width vs. Min-Width

2 Part Answer Part 1: To answer “why people are using min-width over max-width?”: It has to do with design flow. Typically, with min-width patterns, you’re designing mobile-first. With max-width patterns, you’re design desktop-first. Going mobile-first with min-width, the default style is the mobile style. Queries after that then target progressively larger screens. body { … Read more

How can I emulate prefers-color-scheme media query in Chrome?

Since Chrome version 79 you can toggle between prefers-color-scheme: dark and prefers-color-scheme: light from the Rendering panel Open Developer tools (otherwise the key combination below opens the print dialog) Open the Command Control: Ctrl+Shift+P or Command+Shift+P (Mac) Type “Show rendering” Set the Emulate CSS media feature prefers-color-scheme to the value you want to debug

Retina displays, high-res background images

Do I need to double the size of the .box div to 400px by 400px to match the new high res background image No, but you do need to set the background-size property to match the original dimensions: @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { .box{ background:url(‘images/box-bg@2x.png’) no-repeat top left; background-size: 200px 200px; } } EDIT … Read more

Bootstrap – Removing padding or margin when screen size is smaller

The @media query specifically for ‘phones’ is.. @media (max-width: 480px) { … } But, you may want to remove the padding/margin for any smaller screen sizes. By default, Bootstrap adjusts margins/padding to the body, container and navbars at 978px. Here are some queries that have worked (in most cases) for me: @media (max-width: 978px) { … Read more

iPhone 5 CSS media query

Another useful media feature is device-aspect-ratio. Note that the iPhone 5 does not have a 16:9 aspect ratio. It is in fact 40:71. iPhone < 5: @media screen and (device-aspect-ratio: 2/3) {} iPhone 5: @media screen and (device-aspect-ratio: 40/71) {} iPhone 6: @media screen and (device-aspect-ratio: 375/667) {} iPhone 6 Plus: @media screen and (device-aspect-ratio: … Read more