Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grid-style

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grid-style

Grid layout implemented by flex box.

  • 0.3.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
increased by366.67%
Maintainers
1
Weekly downloads
 
Created
Source

grid-style npm Build Status

CSS grid layout which is based on 12 preset columns layout implemented by flex box.

👉Browse online

Installing

# npm
npm i grid-style --save

# yarn
yarn add grid-style
<!-- CDN-->
<link rel="stylesheet" href="https://unpkg.com/grid-style@latest/dist/index.min.css">
<!-- or -->

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/grid-style@latest/dist/index.min.css">
<!-- recommend you to add version number to url ending. eg.https://unpkg.com/grid-style@x.y.z -->

Usage

// import css file to js file
import 'grid-style/dist/index.min.css'
// or
import 'grid-style/dist/index.css'

// a sass alternative to css file
import 'grid-style/layout/index.sass'
/* import css file to your own css file */
@import 'grid-style';

/* or */

/* import sass file to your own sass file */
@import 'grid-style/layout/index.sass'

Basis

selectortargetdescription
.gridcontainerdefine box container
.grid.no-wrapcontainerdisallow wrap item
.grid.colcontainerset flex direction to column
.grid.crcontainerset flex direction to column-reverse
.grid.rowcontainerset flex direction to row
.grid.rrcontainerset flex direction to row-reverse
.grid-cellitemdefine default flex grow factor value of a item
.grid-cell-1 ~ .grid-cell-12itemdefine single item width (based on 1/12 container width
<div class="grid">
  <div class="grid-cell grid-cell-2">
    <!-- something you like -->
  </div>
  <div class="grid-cell">
    <!-- something you like -->
  </div>
</div>

Alignment

selectortargetdescription
.grid-topcontainerdefine alignment per row to top-aligned
.grid-centercontainerdefine alignment per row to vertically-centered
.grid-bottomcontainerdefine alignment per row to bottom-aligned
.grid-jc-startcontainerdefine alignment all item to left-aligned
.grid-jc-endcontainerdefine alignment all item to right-aligned
.grid-jc-centercontainerdefine alignment all item to horizontally-centered
.grid-jc-betweencontainerdefine alignment all item to space-between-aligned
.grid-jc-aroundcontainerdefine alignment all item to space-around-aligned
.grid-cell-topitemdefine alignment per item to top-aligned
.grid-cell-centeritemdefine alignment per item to vertically-centered
.grid-cell-bottomitemdefine alignment per item to bottom-aligned

Notice: You have to make sure all item total width less than container width if you are using .grid-jc- properties. You can use .grid-cell-1 ~ .grid-cell-12 to limit item width.

Online alignment demo

<div class="grid grid-bottom">
   <!-- all child item element will be bottom-aligned excluding grid-cell alignment element -->
  <div class="grid-cell">
    <!-- content of this area will be bottom-aligned -->
  </div>
  <div class="grid-cell grid-cell-center">
    <!-- content of this area will be vertically-centered because of grid-cell-center -->
  </div>
</div>

Gutters

selectortargetdescription
.grid[grid-gutters="1"] ~ .grid[grid-gutters="5"]containerdefine item gutter (based on .5em

Offset

selectortargetdescription
.offset-1 ~ .offset-12itemdefine item offset (based on 1/12 container width

Online offset demo

<div class="grid" grid-gutters="1">
  <div class="grid-cell offset-1">
    <!-- offset 8.33333% * 1 -->
  </div>
  <div class="grid-cell offset-5">
    <!-- offset 8.33333% * 5 -->
  </div>
  <div class="grid-cell offset-6">
    <!-- offset 8.33333% * 6 -->
  </div>
  <div class="grid-cell">
    <!-- no offset -->
  </div>
</div>

Response

Notice: This section define properties to all item (.grid-cell * n) from one container(.grid * 1).

selectortargetdescription
.grid-fullcontainerdefine all item (100% container width) width from same container
.grid-2containerdefine all item (50% container width) width from same container
.grid-3containerdefine all item (33.3333% container width) width from same container
.grid-4containerdefine all item (25% container width) width from same container
.small-grid-fitcontainerdefine flex: 1 , but it only works on device which width over 576px
.small-grid-fullcontainersame as .grid-full , but it only works on device which width over 576px
.small-grid-2containersame as .grid-2 , but it only works on device which width over 576px
.small-grid-3containersame as .grid-3 , but it only works on device which width over 576px
.small-grid-4containersame as .grid-4 , but it only works on device which width over 576px
.large-grid-fitcontainerdefine flex: 1 , it only works on device which width over 768px
.large-grid-fullcontainersame as .grid-full , but it only works on device which width over 768px
.large-grid-2containersame as .grid-2 , but it only works on device which width over 768px
.large-grid-3containersame as .grid-3 , but it only works on device which width over 768px
.large-grid-4containersame as .grid-4 , but it only works on device which width over 768px

Keywords

FAQs

Package last updated on 02 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc