gpt4 book ai didi

sass - 如何使用 sass-breakpoint 实现横向和像素比媒体查询

转载 作者:行者123 更新时间:2023-12-04 20:32:47 25 4
gpt4 key购买 nike

如何用 sass 断点实现这个媒体查询? ...

@media only screen 
and (min-device-width: 375px)
and (max-device-width: 667px)
and (-webkit-min-device-pixel-ratio: 2)
and (orientation: landscape)

我试过这个,但它也会影响桌面版本......
$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) {
}

最佳答案

这是如何使用断点 sass(breakpoint-sass bower 包)实现您想要的。
我已经在 chrome 中尝试过(并使用 web 开发工具模拟设备)并且它可以工作。

// 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;
}
}

如果断点看起来太复杂,您可以使用自己的代码来实现。
例如 :
// 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;
}
}

关于sass - 如何使用 sass-breakpoint 实现横向和像素比媒体查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41918352/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com