Giter Site home page Giter Site logo

wswmsword / postcss-mobile-forever Goto Github PK

View Code? Open in Web Editor NEW
165.0 2.0 13.0 5.65 MB

一款 PostCSS 插件,将固定尺寸的视图转为可跟随宽度变化而等比例伸缩的视图。To adapt different displays by one mobile viewport.

Home Page: https://wswmsword.github.io/examples/mobile-forever/vanilla/

License: MIT License

JavaScript 60.40% HTML 11.83% CSS 14.88% Vue 10.60% Svelte 2.17% SCSS 0.03% TypeScript 0.09%
postcss css-scale media-queries mobile-design pixel-units viewport-units responsive-web-design css postcss-px-to-viewport mobile-first

postcss-mobile-forever's People

Contributors

wswmsword avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

postcss-mobile-forever's Issues

`border` 属性的实现,用 `box-shadow` 去模拟是否会更合适

目前设置开启 border 后,在暗黑模式下左右两侧会显示白边

image

虽然可以设置改变颜色,但 border 会占用实际的空间,导致容器实际宽度会减 2px ,这应该是不符合预期的

image

而用 box-shadow 则不会占用实际的像素,就像这样:

box-shadow: -1px 0 0 0 #ccc, 1px 0 0 0 #ccc;

color属性无效

如: color: #781A05, 会经过转换变为: color: #781A5;
最终浏览器不识别颜色代码, 造成无效

bug: css 变量默认值不转换

输入:

.test {
    font-size: var(--row-font-size, 14px);
}

实际输出:

.test {
    font-size: var(--row-font-size, 14px);
}

希望输出:

.test {
    font-size: var(--row-font-size, min(19.2vw, 99.84px));
}

移动端竖屏不能转换vh单位,请作者大大 麻烦看看 是不是我没配置好

module.exports = {
plugins: {
autoprefixer: {}, //给不同的浏览器添加前缀
"postcss-mobile-to-multi-displays": {
"viewportWidth": 375,
"desktopWidth": 375,
"landscapeWidth": 425,
"yAxisBreakPoint": null,
"xAxisBreakPoint": 375,
"rootClass": "root-class",
"border": false,
"disableDesktop": false,
"disableLandscape": false,
"enableMobile": true,
"pass1px": true,
"exclude": null,
"include": null,
"unitPrecision": 3,
"mobileConfig": {
"propList": ['*'],
"viewportUnit": "vw",
"fontViewportUnit": "vw",
"selectorBlackList": ['van'],
"replace": true
}
},
"postcss-px-to-viewport": {
unitToConvert: 'px', //需要转换的单位
viewportWidth: '375', //视窗的宽度,对应设计稿的宽度 理想视口宽度为375
viewportHeight: '667',//视窗的高度,对应设计搞的高度
viewportUnit: 'vw',//转换的视窗单位
selectorBlackList: ['TabBarItem', '.pc-container','van'], // 指定不需要转换的类
minPixelValue: 1,//小于或者等于1px 不转换
mediaQuery: false,//是否允许媒体查询中转换px
unitPrecision: 5,//转换后的精度,即小数点
// mediaQuery:true
}
}
}

include是否有使用demo

使用vite vue 多页应用,如何只是mobile下面的文件才生效,配置了include: /mobile/,不起效果

设置了之后移动端和pc端是不是都会限制最大宽度

设置如下:
{
"viewportWidth": file => file.includes("vant") ? 375 : 375,
"appSelector": "#app",
"maxDisplayWidth": 600
}

需求:想使用移动端的设计稿,兼容移动端和pc端的显示,我想到的问题就是在pc端会变得非常大,因为pc端是横屏,所以我找到了这个库,按照我的理解就是可以限制一个最大宽度,无论在pc端和移动端只要超过限制就不会发生转换。
问题:当我切换到pc的时候,显示变得异常大,我不知道是我对这个库的使用场景理解有误还是设置有问题?麻烦帮忙看看,需要提供什么额外信息请告知。

uni-app使用

企业微信截图_17142849681058
你好 我在uni-app中使用 报错了 这个怎么改

feat: 支持运行时转换

暴露一个运行时函数,可以进行运行时的代码转换:

transform("750px") ==>  输出100vw

这样行内样式我们可以自己处理(一般行内样式都是用于动态的逻辑处理):

import { transform } from "xxxx";

function A () {
  //宽高比
  const rate = 2;
  return <img src="xxx" width={transform(750)}  height={transform(750/rate)} />
}

配置include和exclude不生效

{
appSelector: '#app',
viewportWidth: 350,
maxDisplayWidth: 600,
include: [//pages/index//],
}
包含和排除都不生效,使用postcss-px-to-viewport配置可以

vue-cli + vue2 + vant2 + postcss-px-to-viewport 不生效

我前段时间使用vite + vue3 + vant4 + postcss-px-to-viewport 根据example-with-postcss-px-to-viewport-vue中的配置,是生效的。这个有一个老的vue2项目,我根据example都试了一编,都没生效,不知道怎么回事

About Nuxt DevTools Width Display

  • Description

When using the maxDisplayWidth property in our plugin, it seems to disrupt the width display in Nuxt DevTools.

  • Steps to Reproduce
  1. Add the plugin to a Nuxt project.
  2. Set maxDisplayWidth.
  3. Observe width display in Nuxt DevTools.
  • Expected Behavior

The maxDisplayWidth property should not affect the display width of Nuxt DevTools.

  • Demo

https://github.com/CharleeWa/nxm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.