How to achieve this media query with sass breakpoint? ...
@media only screen
and (min-device-width: 375px)
and (max-device-width: 667px)
and (-webkit-min-device-pixel-ratio: 2)
and (orientation: landscape)
I've tried this, but it affects the desktop version as well ...
$mobileLandscape: screen and (min-device-width: 375px) and (max-device-width: 667px) and (-webkit-min-device-pixel-ratio: 2) and (orientation: landscape);
@include breakpoint($mobileLandscape) {
}
This is how to achieve what you want with breakpoint sass (breakpoint-sass bower package). I have tried it in chrome (and simulate device with web developper tools) and it works.
// With third-party tool
// Breakpoint https://github.com/at-import/breakpoint
// You can find installation instructions here https://github.com/at-import/breakpoint/wiki/Installation
$mobile-landscape-breakpoint: 'only screen' 375px 667px, (-webkit-min-device-pixel-ratio 2), (orientation landscape);
body {
@include breakpoint($mobile-landscape-breakpoint) {
color: blue;
}
}
If breakpoint seems too complicated, You can achieve this with your own code. For example :
// With Variable
$mobileLandscape: "only screen and (min-device-width: 375px) and (max-device-width: 667px) and (-webkit-min-device-pixel-ratio: 2) and (orientation: landscape)";
@media #{$mobileLandscape} {
body {
color: red;
}
}
// With Mixin
@mixin mq($breakpoint){
@if $breakpoint == "mobile-landscape"{
@media only screen and (min-device-width: 375px) and (max-device-width: 667px) and (-webkit-min-device-pixel-ratio: 2) and (orientation: landscape){
@content;
}
}
}
body{
@include mq("mobile-landscape"){
color: green;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With