GithubHelp home page GithubHelp logo

nikaocreatives / notch-css Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 26 KB

Notch CSS makes it easy for you adjust items on mobile devices with notches

Home Page: https://nikaocreatives.github.io/notch-css/

HTML 100.00%
css notch environment-variables safe-area

notch-css's Introduction

Notch CSS

This is a small project started because I belive in progress web apps or PWAs. I always struggled with the right top and bottom spacing when designing or developing. This repo and demo help me with that issue.

This repo contains one index.html file with some CSS that allows you to set a header and footer that will adjust on each device and set the right padding to get out of the way of those notches. This can be achieved by using env() in CSS, but I hope the demo can provide some clarity when env() is being used and not being used.

The CSS

Its not much, but helps tremendously. You can incorporate this into your header and foot code or just use the classes provided.

:root {
    --sat: env(safe-area-inset-top);
    --sar: env(safe-area-inset-right);
    --sab: env(safe-area-inset-bottom);
    --sal: env(safe-area-inset-left);
}

body {
    padding:
        var(--sat) var(--sar) var(--sab) var(--sal);
    padding-top: var(--sat);
    padding-bottom: var(--sab);
}

.notch--header {
    position: fixed;
    top: 0px;
    width: 100%;
    height: auto;
    padding-top: var(--sat);
    z-index: 100;
}

.notch--footer {
    position: fixed;
    bottom: 0px;
    width: 100%;
    height: auto;
    padding-bottom: var(--sab);
    z-index: 100;
}

The Demo

This demo really helps me as a designer as I'm not sure on the safe areas all the time. It can also can help developers identify when something gets a safe area like safari mobile vs adding a website to your homescreen.

Check out the demo here.

Questions

Reach out with quesitions or comments via twitter or my website.

notch-css's People

Contributors

chasturansky avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

defactiocards

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.