lib-flexible README

The project's README from github.com/amfe/lib-flexible. As one markdown file: README.md.

amfe-flexible

Classic edition (0.3.2)

由于viewport单位得到众多浏览器的兼容,lib-flexible这个过渡方案已经可以放弃使用,不管是现在的版本还是以前的版本,都存有一定的问题。建议大家开始使用viewport来替代此方。

Usage

Install

npm i -S amfe-flexible

Import

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<script src="./node_modules/amfe-flexible/index.js"></script>

You can inline this file with inline-source.

Develop

Use postcss-adaptive.

License

(The MIT License)

Copyright (c) 2016 Alibaba MFE

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

lib-flexible (amfe/lib-flexible)

Searching Database…

What is this?lib-flexible (amfe-flexible) is a legacy mobile web layout library that dynamically sets the root font-size based on the device's screen width, so page elements sized in rem scale proportionally across different screen sizes.
Is this a framework or just a small utility script?It is a small JavaScript snippet/library, not a framework: it just sets the HTML root font-size on load, while a separate build tool (postcss-adaptive) converts your px CSS values into rem.
How do I add it to a project?Install it with npm, then import or inline it into your page so it runs before your stylesheet loads.
Do I need extra build tooling to use rem in my CSS?You write CSS with regular px values and use the postcss-adaptive PostCSS plugin during your build to automatically convert them to rem.
Is this still the recommended way to build mobile layouts?No. The README explicitly says the project should be abandoned now that viewport units (vw/vh) are supported by most browsers, and recommends switching to viewport-based sizing instead.
Why was lib-flexible created in the first place?Before CSS viewport units (vw/vh) had solid cross-browser support, developers needed a way to make rem-based layouts scale with device width, so Alibaba's AMFE team built this root-font-size script as a stopgap solution for mobile responsive design.
Should I start a new project with this today?No — given it's explicitly marked deprecated in its own README in favor of native viewport units, new projects should use vw/vh-based CSS instead of adding this dependency.
Creator
amfe
Size
8.4 MB
Stars
12.5K
Updated
CommitMar 15
Age
12y
Commits · 90 Days