npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

anima-hd

v1.0.5

Published

移动端高清1px方案

Downloads

9

Readme

anima-hd spm version


移动端高清1px方案

Install

$ spm install anima-hd --save

hd效果图

  1. flex模式
  • vw模式
  • vh模式

介绍

  1. anima-hd统一采用rem做单位, 想使用物理1px的就用1px, 比如 border: 1px solid red;
  • 原理是根据rem将页面放大dpr倍, 然后viewport设置为1/dpr.
    • 比如iphone6 plus的dpr为3, 则页面整体放大3倍, 1px(css单位)在plus下默认为3px(物理像素)
    • 然后viewport设置为1/3, 这样页面整体缩回原始大小. 从而实现高清.
  • vw的模式是将rem跟width做关联, 以6.4rem = 100vw做基准.
    • 这么做的好处是设计稿的单位是多少, 除以100就可以给rem来使用;
    • 如果是less之类的预编译, 可以@px: 0.01rem; 然后font-size: 24*@px;来使用!
    • 也可以直接裸写font-size: .24rem;
  • vh同理.
  • 这里不实现vmin|vmax, 实际场景中遇到较少(一般都用flex), 如果有需求, 联系@写轮 添加.
  • 如果一个页面用到了flex + vw, 请用flex模式, vw用百分比或者css的vw等其他方式.
  • 裸写rem: http://k.taobao.net/act/2015/06/intro/intro-lend2.htm

Usage

// 任何页面最佳模式是flex, 搞不定(比如活动页)才会选择vw或vh.
var hd;
// 根据页面所需选择不同的js; 常用的一般为flex和vw!
hd = require('anima-hd/lib/flex.js');
// 这里的vw的横向切分单位是6.4rem = 100vw;
hd = require('anima-hd/lib/vw.js');
// 这里的vw的横向切分单位是7.5rem = 100vw;
hd = require('anima-hd/lib/vw-750.js');
// 这里的vh的纵向切分单位是10.72rem = 100vh;
hd = require('anima-hd/lib/vh.js');

// 一般在viewport的meta标签之下就执行, 效果最佳.
// 如果不是离线包, 推荐直接内联js;
hd();
  • 也可以内联远程js. 由于viewport的设置会引起页面抖动, 强烈建议复制代码内联;
    • https://a.alipayobjects.com/anima-hd/1.0.5/flex.js
    • https://a.alipayobjects.com/anima-hd/1.0.5/vw.js
    • https://a.alipayobjects.com/anima-hd/1.0.5/vw-750.js
    • https://a.alipayobjects.com/anima-hd/1.0.5/vh.js