Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

dimitrinicolas/overflow-color

Repository files navigation

Overflow color

Javascript script that automatically switch css html background color on smartphones.

Try it on your smartphone : git.io/overflow (https://dimitrinicolas.github.io/overflow-color/)

Demo

This package is on npm

$ npm install --save overflow-color

Usage

You simply must add the script and two attributes to your body tag

<body data-oc-top="red" data-oc-bottom="blue">
    <!-- ... -->
    <script src="overflow-color.min.js"></script>
</body>

CSS tricks

Behind the Scenes

This library will wrap all the body content inside a <div data-oc-wrap>. Then it set to the wrapper the same background as the body, and set body's background to transparent.

when the document is loaded:

<head>
    <!-- ... -->
    <style>
        body {
            background: lightgrey;
        }
    </style>
</head>
<body data-oc-top="red" data-oc-bottom="blue" style="background: transparent;">
    <div data-oc-wrap style="background: lightgrey;">
        <!-- ... -->
        <script src="overflow-color.min.js"></script>
    </div>
</body>

Build

Minify script

$ npm run build

About

Automatically switch CSS html background-color to bring a smooth user experience

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published