GithubHelp home page GithubHelp logo

rlugojr / bootstrap-breakpointify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bitjson/bootstrap-breakpointify

0.0 2.0 0.0 7 KB

Fight class creep with breakpoint suffixes for Bootstrap v4's utilities.

License: MIT License

CSS 100.00%

bootstrap-breakpointify's Introduction

npm GitHub issues GitHub license

bootstrap-breakpointify

Fight "class creep" by adding breakpoint suffixes to Bootstrap v4's utility classes.

For example, .m-a-1-gt-md:

  • applies Bootstrap's "size 1" margin to all sides (the m-a-1 Bootstrap class)
  • at Bootstrap breakpoints greater than medium (gt-md).

Purpose

As a web project grows – and particularly as new contributors begin making changes to CSS – it's common for simple utilities to be used and re-used in dozens of ways. Without using "breakpointified" utilities, each usage tends to add both to the project weight and to the difficulty of grokking the entirety of the project's CSS.

Especially when "one-use" classes are repeatedly developed (eg: when a website contains multiple very unique landing pages), many projects tend to grow a base of "write-only CSS" (becuase editing "old" CSS is tedious and requires good visual testing).

Using "breakpointified" utilities can help slow this "class creep" in your projects.

Install

npm install bootstrap-breakpointify

Or:

bower install bootstrap-breakpointify

Note: this library must be @imported after bootstrap, as it requires Bootstrap's responsive breakpoint mixins.

@import '../bower_components/bootstrap/scss/bootstrap';
@import '../bower_components/bootstrap-breakpointify/all';

Usage

Breakpoint suffixes are appended to the end of the normal classes. See the bootstrap docs for more information. All suffixes begin with either gt ("greater than") or lt ("less than").

"Greater-than" suffixes

"Greater-than" suffixes apply the class at the following Bootstrap breakpoints.

suffix x-small small medium large x-large
gt-xs
gt-sm
gt-md
gt-lg

"Less-than" suffixes

"Less-than" suffixes apply the class at the following Bootstrap breakpoints.

suffix x-small small medium large x-large
lt-sm
lt-md
lt-lg
lt-xl

Available Prefixes

This library "breakpointifies" all of Bootstrap's utility clases.

Properties – First Character

  • m – margin
  • p - padding

Direction(s) – Second Character

  • t - top
  • r - right
  • b - bottom
  • l - left
  • x - x-axis (both left and right)
  • y - y-axis (both top and bottom)
  • a – all (all of the above: top, right, bottom, and left)

Size – Third Character

  • 0 – none
  • 1 – normal (the relevant Bootstrap $spacer value)
  • 2 – size 2 (the relevant Bootstrap "size 2" value – by default, $spacer * 1.5)
  • 3 – size 3 (the relevant Bootstrap "size 3" value – by default, $spacer * 3)

Examples

  • m-a-0-gt-lgmargin all size 0 greater than large – remove margin from all sides at breakpoints greater than Bootstrap's large (lg) breakpoint.
  • m-b-3-gt-mdmargin bottom size 3 greater than medium – apply "size 3" margin-bottom at breakpoints greater than Bootstrap's medium (md) breakpoint.
  • p-t-1-lt-mdpadding top size 1 less than medium – apply normal padding-top at breakpoints less than Bootstrap's medium (md) breakpoint.

What about unused CSS classes?

You could use UnCSS to programmatically remove unused CSS, but it's likely not worth the savings.

Browser rendering performance is not impacted by unused CSS classes, and this entire library adds the equivalent of a small icon to your page weight. Ensure your stylesheets are served with gzip compression for best optimization.

bootstrap-breakpointify's People

Contributors

bitjson avatar wconnorwalsh avatar

Watchers

 avatar  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.