Coder Social home page Coder Social logo

lzxb / flex.css Goto Github PK

View Code? Open in Web Editor NEW
1.5K 69.0 358.0 441 KB

flex.css is declarative layout which is compatible with wechat, UC, webview and other main-stream mobile browser and surpports react, vue, angular.

JavaScript 15.88% Less 84.12%
css flex vue react angular flexbox flexbox-css flex-layout flexible

flex.css's Introduction

npm npm npm

中文文档入口
如果对状态管理感兴趣,可以看下 Tms,文档更齐全

Download

git clone https://github.com/lzxb/flex.css.git

npm

npm install flex.css --save

Why do you need flex.css?

In the process of Mobile Terminal Development, standard flex is not supported by all versions of all kinds of
browsers, webview, and wechat which basically support  -webkit-box. So flex.css's main purpose is to ensure
that every attribute can be supported by standard version's flex or old-version's -webkit-box.
due to autoprefixer compilation is used by flex.css,it will roll back to old-version's -webkit-box when standard
flex is not supported by some browsers so the effect of layout will be the same.
Then,here comes a magic effient layout tool of mobile terminal development ...

Merits

Concise api, 
familiar attribute values, makes it easy for you to get started in using flex.css.
In html, the layout is bind with attributes, so it is seperated from css. In this way, it will be easier for you
to maintain and modify your layout without modifying css.

Support

flex layout is split into three versions: old version: display: box; , transitional version: display:flexbox; ,
and present standard version: display:flex; .
Android
2.3  began to support old version: display: -webkit-box;
4.4 began to support standard version: display: flex;
IOS
6.1  began to support old version: display: -webkit-box;
7.1 began to support standard version: display: flex;
PC
You can use flex.css if you don't need to consider IE10-.
flex.css is compatible with standard version and old version at the same time, so when a browser doesn't support standard version, it will roll back to old version.

Alt text

Use

<!--
According to what you need, include css files in the dist directory into your html
flex.css should be matched by flex attribute
data-flex.css should be matched by data-flex attribute(used by React)
If you use webpack to package, after npm is installed, and ES6 compiler is deployed in your project,
flex attribute matching can be implemented in this way:
import 'flex.css';
data-flex attribute matching can be implemented in this way( used by React):
import 'flex.css/dist/data-flex.css';
 -->
<!-- flex attribute matching,a simple example of centering child element : -->
  <div flex="main:center cross:center" style="width:500px; height: 500px; background: #108423">
    <div style="background: #fff"> to see if this is in the center </div>
  </div>

<!-- data-flex attribute matching,a simple example of centering child element: -->
  <div data-flex="main:center cross:center" style="width:500px; height: 500px; background: #f1d722">
    <div style="background: #fff"> to see if this is in the center </div>
  </div>

Collection of flex attributes

dir: axis direction
    top:from top to bottom
    right:from right to left
    bottom:from bottom to top
    left:from left to right( default )
main:axis align
    right:from right to left
    left:from left to right ( default )
    justify:justify align
    center:center align
cross:cross axis align
    top:from top to bottom ( default )
    bottom:from top to bottom
    baseline:baseline align
    center:center align
    stretch:cover whole area 
box:child element setup 
    mean:space is split by child elements equally
    first:spare space is  not given to the first element and split by the rest of child elements equally
    last:spare space is  not given to the last element and split by the rest of child elements equally
    justify:spare space is  not given to both of the first element of each end 
	and split by the rest of child elements equally

Flex-box attributes description

values range ( 0-10 ), how to asign spare space to individual child element: if the value equals 0,there won't 
be any spare space for this child element.
spare space assignment = current value of flex-box / the sum of all values of child element's flex-box 

Demo

demo

Other demo

demo

flex.css's People

Contributors

barnett617 avatar bibiuc avatar lzxb 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  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

flex.css's Issues

ios8.3 兼容性问题;

你好;我做了两个项目,都是引入了flex.css 但是有一个项目发现并没有自动添加-webkit-的前缀;导致在ios下有兼容性问题。想知道是为什么?

on olde version webkit dir:top flex-box first children node disappear。

dir:top 下 flex-box 中第一个节点,在旧版本 webkit 浏览器中会显示不出来,(英语太差了,还是汉语吧(lll¬ω¬))
加上
[flex~="dir:top"] > [flex-box] > * {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
就可以了,测试机型 万恶的opp vivo

在小程序中引入flex问题

你好,在小程序中引入flex报错。您尝试过吗?
./pages/index/index.wxss
error at token "*"
9 | display: flex;
10 | }

11 | [flex] > * {
| ^
12 | display: block;
13 | }
14 | [flex] > [flex] {

盒子内部定位元素需要超出盒子不能显示问题

由于flex设置了overflow:hidden,则应用场景为盒子内部的定位元素需要超出盒子就不能显示出来了。
建议用其他清除浮动方式撑起盒子适应内部内容。如:给父元素加伪元素:after,样式清楚浮动就行

flex-box="1" 这个样式里面为何没有 flex-basis ?

既然flex-box="1"是设置flex,那为什么没有定义flex-basis
因为这个,我给三个元素的头尾两个元素设置flex-box="1",希望他们有一样的size,结果因为第一个元素内部有文字内容,所以比最后的元素大。

flex overflow make some bug

when I use the flex.css,the over:flow:hidden always make some bug, In some android phone, If the <p><p> use the flex.css,they alaways was cliped by the flex.css.I hope you can modify the bug. thanks

在使用你的flex.css时,overflow:hidden 经常会造成一些bug,会将div的超出部分裁掉,在一些烂安卓手机上,当给p段落使用时,也会造成段落上面被裁掉的现象,应该也是overflow引起,我可以直接将overflow:hidden注释掉么,这样会不会造成什么问题。希望能抽空改进一些,谢谢!

直接引入dist中的flex.css, 不管用

首先很感谢你们。我把dist目录中的flex.css拷贝到了我的本地。然后发现在安卓4.2上不管用。在5.1上是好的。请问这是什么原因。

非常喜欢你们的flex布局!但想请教是否有这种布局方法。

感觉很幸运,第一次接触flex布局就遇到了你们,这种属性的写法,优雅程度完胜那些写在class里面的。

但是对于flex布局还有很多不太熟悉的地方,虽然已经被他那么优雅的对齐方式给惊艳了。

现在有个问题,如果我想实现这样的布局,
qq20161130-0

每张图片外我给他包裹了一个长宽一致的div,这样比较好看,这时候第四章图片就出现排放问题了,如果我想出现一个滚动条,可以往右滚一下看完全部图片,或者说第四张图片换一行展示,不知道在flex的情况下该如何新增样式呢?

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.