Giter Site home page Giter Site logo

cn-kicoyu / tagsalign Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 2.0 60 KB

计算多个标签的位置 / 标签根据文字自适应宽度 / 每行超过的宽度平均分配给每个标签 / 每行标签左右对齐

HTML 69.08% JavaScript 30.92%
tags align select

tagsalign's Introduction

TagsAlign

打造一款可以实现宽度自适应,但是两端能对齐的tab标签集合:poultry_leg:

函数功能

  • [√] 计算多个标签的位置
  • [√] 标签根据文字自适应宽度
  • [√] 每行超过的宽度平均分配给每个标签
  • [√] 每行标签左右对齐
  • [√] 每行个数自适应或者固定

使用方法

直接调用函数tagsAlign(),支持三个参数:

  • [ element ] ul对应的id,必传
  • [ cols ] 每行最多展示的个数, 选传,不传为自适应
  • [ space ] 每两个li之间的间距, 选传,不传时默认为10px

效果展示

每行个数自适应,例如tagsAlign('fromList') 截图展示

固定每行最多展示个数,例如tagsAlign('studyList', 4); tagsAlign('caseList', 3) 截图展示

温馨提示

如果是用前端MV*框架,请在DOM元素已经渲染之后执行该函数。 函数源码已放出,需要的话可以根据自身需求定制

tagsalign's People

Contributors

cn-kicoyu avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

paper lie2believe

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.