Giter VIP home page Giter VIP logo

responsive-grid's Introduction

Responsive Grid

Responsive grid is a minimal implementation of a 12-column mobile-first responsive grid. It is based on code from the w3schools.com Responsive Web Design tutorial.

Usage

Simply include grid.css in your HTML document. To define the number of columns you want an element to take up, give it the col-[x] class, where x is a number from 1 to 12. You can also specify different widths for different screen sizes. col-2 will take up 2 columns on desktop screens, and all 12 columns on smaller screens. col-m-2 will take up 2 columns on desktop and tablet screens, and all 12 columns on mobile screens. col-s-2 will take up 2 columns on all screen sizes mobile and larger. These can be combined - col-4 col-m-6 col-s-8 will take up 4 columns on desktop screens, 6 columns on tablet screens, and 8 columns on mobile screens.

You can push elements to the right a certain number of columns using the push-[x] classes, where x is the number of columns to push the content. These are also separated by size, so push-2 will push the content 2 columns to the right on desktop screens, push-m-2 will do the same on desktop and tablet screens, and push-s-2 will do the same on mobile screens and larger. These can be combined, so, for instance, push-2 push-m-3 push-s-4 will push the content over 2 columns on desktop screens, 3 columns on tablet screens, and 4 columns on modile screens.

Example

<link rel="stylesheet" type="text/css" href="https://jdormit.github.io/responsive-grid/grid.css">
<div class="row">
    <div class="col-12">
        This text will take up the whole row on all screen sizes.
    </div>
</div>
<div class="row">
    <div class="col-m-12 col-6">
        This text will take up a whole row on screen sizes < 768px,
    </div>
    <div class="col-m-12 col-6">
        but only half a row on larger screens.
    </div>
</div>
<div class="row">
    <div class="col-s-12 col-m-6 col-3">
        This text will take up a whole row on screen sizes < 414px,
    </div>
    <div class="col-s-12 col-m-6 col-3">
        half a row on screen sizes between 415px and 768px,
    </div>
    <div class="col-s-12 col-m-6 col-3">
        and a quarter of a row
    </div>
    <div class="col-s-12 col-m-6 col-3">
        on larger screens.
    </div>
</div>
<div class="row">
    <div class="col-s-4 push-s-4">
        This text will take up the middle 4 columns on all screens.
    </div>
</div>
<div class="row">
    <div class="col-2 push-2 col-m-3 push-m-1 col-s-4">
        This text will be 2 columns wide separated by 2 empty columns on large screens,
    </div>
    <div class="col-2 push-2 col-m-3 push-m-1 col-s-4">
        3 columns wide separated by 1 empty column on medium screens,
    </div>
    <div class="col-2 push-2 col-m-3 push-m-1 col-s-4">
        and 4 columns wide with no separation on small screens.
    </div>
</div>

This example is reproduced in example.html, which is hosted here.

If you want to play around with it yourself, check out the JSFiddle.

Installation

grid.css is served on Github pages. To include it in your html file, use:

<link rel="stylesheet" type="text/css" href="https://jdormit.github.io/responsive-grid/grid.css">

To download the file (in terminal):

wget https://jdormit.github.io/responsize-grid/grid.css

Or simply download from here.

responsive-grid's People

Contributors

jdormit avatar

Watchers

James Cloos 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.