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

mobile.flexible.css

v1.0.2

Published

flexible-css 移动页面rem实现自适应

Downloads

3

Readme

mobile.flexible.css

说明

  • 页面在渲染过程中CSS执行是优于JS执行的,在flexible.js做html的fontsize的自适应过程,页面初始化会有明显的闪动,为了解决这一问题,我用CSS来替代JS的执行。
  • mobile.flexible.css的原理同flexible.js相同,都是修改了fontsize,不同的是使用SCSS把自适合尺寸的CSS提前渲染好了。
  • 默认html页面最大宽设为540px,你可以使用对等设计稿750px的flexible.750.css
  • mobile.flexible.css的雏形是用em,当初是以父级自适应子元素盒子,原因是2015年前大部分手机对rem兼容性差,但对媒体查询兼容性很好。
  • CDN: https://cdn.jsdelivr.net/gh/liseipi/[email protected]/css/flexible.css

配合HTML最大宽度使用

@improt 'mobile.flexible.css/css/flexible.css'

html {
  max-width: 540px;
  margin: 0 auto;
  background-color: #f8f8f8;
  min-height: 100%;
  overflow-x: hidden;
  box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.1);
  font-size: 32px;
}

使用

采用750布局,设计稿尺寸为750px时使用SCSS计算

@function REM($px) {
  @return $px / 750 * 1rem;
}

默认采用540布局,设计稿为750px时可以计算到,540/750=0.72

@function REM($px) {
  @return $px / 540 * 0.72 * 1rem;
}