Coder Social home page Coder Social logo

craigmdennis / rwdcss Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 13 KB

Generate responsive CSS classes using a single SCSS mixin and a variable map

Home Page: http://codepen.io/craigmdennis/post/generate-responsive-bemit-classes-with-sass

CSS 79.43% JavaScript 20.57%

rwdcss's Introduction

RWD

Generate responsive CSS classes using a single SCSS mixin and a variable map

Edit on CodePen

Installation

Downaload and @import into your main scss file

Create breakpoints

The current syntax is set up to use Bourbon Neat's media Breakpoint's breakpoint mixin.

$breakpoints: (
  mobile: max-width 47.9375em,
  tablet: 48em,
  hd: 62em
);

Call the mixin

This will output content with the base class name as well as any breakpoints specified.

.component {
  @include rwd( mobile tablet hd ) {
    color: white;
    background: black;
  }
}

// .component {}
// .component--MQmobile {}
// .component--MQtablet {}
// .component--MQhd {}

If you only want a specific breakpoint and no base class, pass false as the second argument

.component {
  @include rwd( mobile, false ) {
    color: white;
    background: black;
  }
}

// .component--MQmobile {}

Global settings

If you want to change the prefix you can add a settings map to your variables file

$rwdcss: (
  prefix: \@
);

// Default is "---MQ"

NOTE: Don't include the backslash in the HTML; it is purely to escape that character in CSS / SCSS

.component {
  @include rwd( mobile, true ) {
    color: white;
    background: black;
  }
}

// .component\@mobile {}
// <div class="component@mobile">This is only black <b>upto 48em</b></div>

Use the classes

<div class="component">This is always black</div>
<div class="component---MQmobile">This is only black <b>upto 48em</b></div>
<div class="component---MQtablet">This is only black at <b>48em wide</b></div>
<div class="component---MQhd">This is only black at <b>62em wide</b></div>

rwdcss's People

Contributors

ahmednuaman avatar craigmdennis avatar

Watchers

 avatar  avatar

Forkers

hellofiremind

rwdcss's Issues

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.