Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

媒体查询中的 vw 转换 #30

Closed
1390006090 opened this issue Mar 28, 2024 · 10 comments
Closed

媒体查询中的 vw 转换 #30

1390006090 opened this issue Mar 28, 2024 · 10 comments

Comments

@1390006090
Copy link

可以添加视口宽度吗??跟随横竖屏 更换时候宽度

@wswmsword
Copy link
Owner

不好意思,没理解您的意思

@1390006090
Copy link
Author

  postcsspxtoviewport8plugin({
      unitToConvert: 'px', // 需要转换的单位,默认为"px"
      viewportWidth: 1080, // 设计稿的视口宽度
      mediaQuery: true, // 媒体查询里的单位是否需要转换单位
      unitPrecision: 6, // 单位转换后保留的精度
      landscape: true, // 是否添加根据 landscapeWidth 生成的媒体查询条件 @media (orientation: landscape)
      landscapeUnit: 'vw',// 横屏时使用的单位
      landscapeWidth: 1920,// 横屏时使用的视口宽度

@1390006090
Copy link
Author

landscape: true, // 是否添加根据 landscapeWidth 生成的媒体查询条件 @media (orientation: landscape)
就是这个功能

@wswmsword
Copy link
Owner

{
  "viewportWidth": 1080,
  "appSelector": "#app",
  "enableMediaQuery": true,
  "landscapeWidth": 1920,
}

插件可以设置媒体查询横屏下的视口宽度,您看下这个符合你的需求吗?上面的 "landscapeWidth": 1920 设置了横屏时的视口宽度 1920 像素,如果再设置 "desktop: xxx",就是设置桌面端的视口宽度为 xxx。

@1390006090
Copy link
Author

  "mobileUnit":"vw",
      "viewportWidth": 1080,
      "appSelector": "#app",
      "enableMediaQuery": true,
      "landscapeWidth": 1920,
      "desktopWidth":1920

Uploading 1711616172196.jpg…

@1390006090
Copy link
Author

@media (min-width: 1920px) and (max-height: 640px), (max-width: 1920px) and (min-width: 1920px) and (orientation: landscape)

<style> .index-container .index-introduce[data-v-93195b7f], .index-container .index-menu[data-v-93195b7f] { height: 1848.889px;

@1390006090
Copy link
Author

转换出来成这样了

@1390006090
Copy link
Author

没转成vw还是px

@wswmsword
Copy link
Owner

转换的媒体查询代码,里面的单位是 px,这是因为匹配到媒体查询后,视图应该是保持不变的,也就是固定尺寸的。如果你看非媒体查询的代码,都已经转换为 vw 了。

@1390006090
Copy link
Author

我以为都会转换....

@wswmsword wswmsword changed the title 可以 媒体查询中的 vw 转换 Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants