GithubHelp home page GithubHelp logo

mediahack's Introduction

Mediahack

Add media query classes to DOM nodes

mediahack adds classes to a DOM node when media queries are matched, for instance setting 'portrait' when a tablet is in portrait.

This makes it easy to write css selectors for these options without long-hand media queries all through your css.

Check out the demo

Mediahack is only 0.8kb at it's thinnest point*

Usage

Simply pass an element you'd like decorated with media classes:

mediahack(document.body);

Then make use of css to do the rest:

body.portrait div.sidebar {
    display: none;
}

Distributions

Mediahack comes in three delicious flavours: Vanilla, Strawberry and Chocolate.

Please see POLYFILL-LICENCE.txt for the BSD/Copyright notice for MediaMatch.

Default class / queries

By default, the following classes will be added when their media query is matched:

  • landscape 'all and (orientation:landscape)'
  • portrait 'all and (orientation:portrait)'
  • small 'all and (max-width:768px)'
  • medium 'all and (min-width:768px) and (max-width:991px)'
  • large 'all and (min-width:992px)'

mediahack() takes an optional second argument, an object containing your own matches if you'd like to overwrite the defaults.

Licence

MediaHack is (c) 2013 Pomke Nohkan and is made available to you under an MIT Licence.

mediahack's People

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.