GithubHelp home page GithubHelp logo

okydk / basegrid Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 1.0 84 KB

Dynamic CSS-grid base on CSS-variables. ๐Ÿ”ฅ

Home Page: https://base.grid.studio/

License: MIT License

CSS 100.00%
css-grid grid-system dynamic css-variables

basegrid's Introduction

Basegrid ๐Ÿ›  NPM version

The smallest and most flexible grid-system possible.

Requires CSS-grid and CSS-variables. (Firefox 31+, Chrome 49+, Safari 9.1+, Opera 36+, Edge 16+)

Features

  • Lightweight (0.6KB)
  • No dependencies
  • Flexible AF
  • Dynamic grid attributes
    • gw: Grid width (940px)
    • gg: Grid gap (20px)
    • gc: Grid columns (12)
    • gr: Grid row height (auto)
  • Dynamic section attributes
    • w: Width (1)
    • h: Height (1)
    • x: Column position (auto)
    • y: Row position (auto)

Examples

Include css either via CDN or install via NPM.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/basegrid">

Grid samples

// Simple grid
<div class="basegrid"></div>

// Fixed grid (equal width and height)
<div class="basegrid fixed"></div>

// Responsive grid
<div class="basegrid res"></div>

Section samples (using fixed grid)

<!-- Fixed grid with: -->
<div class="basegrid fixed">
	<div style="--w:5;">5 columns wide</div>
	<div style="--w:5;--h:5;">And 5 high</div>
	<div style="--w:5;--h:5;--x:3;--y:3;">With fixed position</div>
</div>

<!-- Variable height and commen width (masonry) -->
<div class="basegrid fixed" style="--w:4;">
	<div style="--h:3;">3 high</div>
	<div style="--h:2;">2 high</div>
	<div style="--h:4;">4 high</div>
	<div style="--h:3;">3 high</div>
	<div style="--h:4;">4 high</div>
	<div style="--h:2;">2 high</div>
</div>

<!-- Overlapping with fixed coordinates and size -->
<div class="basegrid fixed" style="--w:4;">
	<div style="--x:1;--y:1;--w:8;--h:8"></div>
	<div style="--x:3;--y:3;--w:8;--h:8"></div>
	<div style="--x:5;--y:5;--w:8;--h:8"></div>
</div>

basegrid's People

Contributors

okydk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sgrives

basegrid's Issues

Not an issue, more of a question

I am quite comfortable with flexbox(been using from the early implementations), but I still haven't found time to properly learn CSS grid.

I've read(skimmed) a few articles, just to gain some understanding how it works. But that is it.

Then I stumbled upon your nice mix of grid and custom properties, and that got my attention.

My question is are there any downsides to just using your library compared to writing layouts with the whole grid spec at disposal.

Are there some layouts/stuff that can't be just built by using your library, or it will cover for most use cases?

How to change x/y or w/h values per breakpoint

Since --x , --y, --w and --h are declared inline, is it possible to change those at certain breakpoint?

I find it common to change column size per certain breakpoint. Also positioning items differently with --x and --y would be very handy.

p.s. Maybe what I am asking is too much, but do you maybe have an example of a simple responsive layout built with basegrid? A Codepen or similar?

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.