Code Monkey home page Code Monkey logo

flex-polyfill's Introduction

flex-polyfill

flex布局的兼容方案,对flexibility的封装。

相对于直接接入flexibility,这里做了动态按需加载以及多种接入方式的支持。
后续使用过程中如果有什么问题,方便统一升级或回滚处理。

CSS写法

  .container {
    // 在使用flex的选择器中增加这一声明就可以了
    // flexibility会据此进行降级方案构建
  	-js-display: flex;
  	
  	display: flex;
  }

使用

  • 调用参数
  let options = {
    // 使用flex布局的元素,可以不传(以下为默认值)
    elem: document.documentElement,
    // flexibility.js地址,可以不传(以下为默认值)
    src: '//j1.58cdn.com.cn/git/flex-polyfill/lib/flexibility.js'
  };
  • NPM包引用方式
  // 安装
  npm i -S flex-polyfill
  // es6
  import flexPolyfill from 'flex-polyfill';
  // cmd
  let flexPolyfill = require('flex-polyfill');
  flexPolyfill(options);
  • 全局引用方式
  <script src="./dist/index.min.js"></script>
  window.flexPolyfill(options);
  • 加载器引用方式
  // CMD
  let flexPolyfill = require('./dist/index.min');
  flexPolyfill(options);
  // AMD
  requirejs(['./dist/index.min'], function(flexPolyfill) {
    flexPolyfill(options);
  });

注意事项

  • flex仅支持flex-grow
  • align-items: stretch的情况下,flex-directionrow切换到column可能会失败

尽量避免使用复杂的特性组合,此方案不能完备地支持标准的全部内容,支持情况

flex-polyfill's People

Watchers

 avatar

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.