GithubHelp home page GithubHelp logo

etoxin / browser-classes Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 74 KB

Adds browser classes to document body. For better browser css bug fixing.

JavaScript 96.20% HTML 3.80%
browser javascript internet-explorer

browser-classes's Introduction

browser-classes

Codacy Badge

Adds browser classes to document body. For better cross browser SCSS styling.

This library adds the current browser and version to the <body> tag as a class to the site.

Once you run the class, your <body> tag will have the following class added.

<body class="browser-firefox-65">
<body class="browser-ie-10">

Installation

npm i --save browser-classes

Usage

import BrowserClasses from 'browser-classes';
new BrowserClasses();

SCSS Usage

Use the @at-root method when using with SCSS

.myClass {
    color: red;
    @at-root .browser-ie-10 {
        color: blue
    }
}

This will target Internet Explorer 10 with browser-ie-10 added to the body tag.

<body class="browser-ie-10">

Javascript usage

The below method can test for Internet Explorer 9

if (document.body.classList.contains('browser-ie-9')) {
    // fix
}

Browser only targeting

To target only a certain browser not by version use the following syntax.

CSS
body[class^="browser-firefox"] {
    color: red;
}

Browser Support

Currently this library identifies the following browsers:

  • Chrome
  • Internet Explorer
  • Edge
  • Safari
  • Firefox

Example class names for browsers

Below arte some examples of the classes that will be generated for the browsers.

Browser Class
Internet Explorer 10 <body class="browser-ie-10">
Edge 12 <body class="browser-edge-12">
Google Chrome 50 <body class="browser-chrome-50">
Firefox 60 <body class="browser-firefox-60">
Safari 11 <body class="browser-safari-11">

browser-classes's People

Contributors

benmccallum avatar codacy-badger avatar etoxin avatar isobar-alusted avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

browser-classes's Issues

Show operating system

Would be nice to show operating system. eg. browser-osx-chrome-64 or browser-osx-chrome.

Include browser only class.

Currently the lib shows browser-firefox-64. I would like to include browser-firefox as well as browser-chrome

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.