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

flex-stylus-class

v0.1.6

Published

classes of flex-stylus

Downloads

4

Readme

flex-stylus-class

🍓classes of flex-stylus

使用stylus预处理器封装的flex布局类~ 只提供源码 业务项目自行构建

目标

  • 简化常用布局✂️
  • 解决一次又一次的布局兼容性问题😤ios >= 8 android >= 4.3

安装

    npm i flex-stylus-class --save-dev

or


    yarn add flex-stylus-class

使用

    // @file index.styl
    @import '~flex-stylus-class'

or

    // @file index.js
    import 'flex-stylus-class'

建议配置环境

  • 建议使用webpack4构建工具
  • 建议使用postcss-loader + autoprefixer + cssnano进行样式的兼容性、代码压缩处理

安装环境依赖

// install
yarn add postcss-loader autoprefixer cssnano

配置文件

// @file postcss.config.js
module.exports = {
    plugins: [
        require('autoprefixer'),
        require('cssnano')({
            preset: 'default'
        }),
    ]
};
// @file package.json browserslist
...,
"browserslist": [
    "iOS >= 8",
    "Android >= 4.3"
  ]

特别注意browserslist中一定要写ios >= 8, 否则iphone5s (ios8.3)会出现布局错乱的兼容性问题。

Demos

业务styl

body *
    box-sizing border-box

.item
    height 50px
    width 50px
    background-color #E0E0E0
    margin 10px

section
    border 1px solid #424242

.section-200
    height 200px
    width 200px

普通flex布局

<section class=" c__flex">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</section>

等分flex

<section class=" c__flex c__flex-auto">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</section>

自动折行

<section class=" c__flex c__wrap">
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
</section>

content居中

<section class=" c__flex c__center">
    <div class="item"></div>
    <div class="item"></div>
</section>

c__between / c__around 内容散列

// space-between 写法
<section class=" c__flex c__wrap c__between">
// space-around 写法
//  <section class=" c__flex c__wrap c__around">
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
</section>

父元素和子元素配合

<section class="section-200 c__flex c__around">
    <div class="item"></div>
    <div class="item i__middle"></div>
    <div class="item i__bottom"></div>
</section>

垂直居中

<section class="c__vertical c__flex c__middle">
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
</section>

水平垂直居中

<section class="section-200 c__flex c__center c__middle">
    <div class="item"></div>
</section>

水平flex中嵌入垂直flex布局 水平方向等分

<section class="c__flex  c__flex-equal">
    <section class="c__flex c__vertical c__middle">
        <div class="item"></div>
        <div class="item"></div>
    </section>
    <div class="item"></div>
    <div class="item"></div>
</section>

垂直flex布局中嵌入水平flex布局

特别注意ios10-已知的flex-direction:columnbug, 父元素为垂直flex布局时,子元素必须为display:block元素,所以要像下面这样,在水平flex元素外套一层block元素。

<section class="c__flex c__vertical c__middle">
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <section>
        <div class="c__flex">
            <div class="item"></div>
            <div class="item"></div>
        </div>
    </section>
</section>

License

MIT