
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
In short, Crispy Grid closes the gap between easy-to-use grids for simple web pages and doing everything by hand due to layout complexity.
CSS grid frameworks like Blueprint and 960.gs try to realize their higher level concepts using only margins and relative positioning.
Often, this is in conflict with CSS box semantics. In CSS, whitespace surrounding content should be expressed as padding of the containing element. Margins should be used for defining whitespace among sibling elements.
A common workaround for paddings and margins within a grid is using inner wrapping elements which are save to style. This is unsemantic and clutters up the template.
Crispy respects padding and border box properties.
Unlike Lucid Grid (which I recommend as an alternative), padding and border width can be set along with the column width in one statement. Crispy does the calculation for you.
Whenever you try to realize a page that simply does not fit into the predefined columns, you are likely to catch yourself fighting with the grid. Likewise, most grids are not meant to be applied on more than the big containers (navigation, sidebar, main, etc.). Yet it would be nice to have a tool for specifying the layout of the inner elements in a smart way.
Crispy tries to support you even if you go beyond the main grid.
In your Gemfile add:
gem 'crispy-grid'
Skip this step if you have Rails >= 3 and Compass >= 0.11.
In your project configuration file (e.g. initializers/compass.rb, you might want to create one if it does not exist yet) add:
require 'crispy-grid'
Customize and import the grid in your application stylesheet:
Tell Crispy Grid to use a single device by setting the singular
configuration options $device
, $grid-column-width
, and grid-gutter-width
.
// Copy this into your app in order to customize the grid
$device: desktop
$grid-column-width: 30px
$grid-gutter-width: 10px
$grid-columns: 24
// Import Crispy Grid below the configuration
@import crispy/grid
In $devices
you can list all devices you whish to respond to.
The nth entry of any of the following lists belongs to the nth device (the order of $devices
matters).
The first device is the default for all grid helpers.
Consider to set mobile as default device when following the mobile-first design approach.
// Copy this into your app in order to customize the grid
$devices: desktop, tablet, handheld-640, handheld-320
$grid-column-widths: 30px, 30px, 20px, 20px
$grid-gutter-widths: 10px, 10px, 5px, 5px
$grid-columns: 30, 24, 24, 13
// Import Crispy Grid below the configuration
@import crispy/grid
By default, Crispy Grid mimics this more natural behavior for a box-sizing: content-box setting by doing calculations. If you start a new project and do not have to support IE7, we recommend you to use box-sizing: border-box instead.
When switching an old project to border-box-sizing you need to tell Crispy Grid so. This is as simple as initializing it with $grid-box-sizing
like so
...
$grid-box-sizing: border-box
// Import Crispy Grid below the configuration
...
Setting the $grid-box-sizing
to border-box
will tell the grid to
ignore its padding calculations as they are no longer needed when using
the border-box
box-model. However this will not apply border-box
to
your elements. Most likely you'll want to apply border-box
to all your
elements. The way Paul Irish recommends looks like this when using Compass.
*
+box-sizing(border-box)
In most cases this will be the way to go. However, there might be the
edge cases where you don't want to apply border-box
to all your
elements. That's why setting the box-model is not part of Crispy Grid's
$grid-box-sizing
option.
Crispy is fully capable of creating percentage based grids. However, when creating a fluid grid border-box
should be used.
Nesting columns is tricky with fluid grids. Crispy provides the fluid-sub-column
mixin to help with nested columns. (See below)
The only things you need to know for using Crispy Grid are these 3 mixins:
+grid-container
+column
+column(5)
to span 5 columns, each having a gutter to the right-hand side.+last
Use might also find these mixins useful:
+last-column
+column
and +last
. You should favor it over the two in order to reduce CSS output.+row
+column
with the configured count of $grid-columns
.+fluid-sub-column
+fluid-sub-column(2, 4)
) and Crispy will calculate a width and gutter as if the column was not nested.+column
, +last-column
, +row
, +fluid-sub-column
$colspan
+column(5)
, +column(120px)
, +row($colspan: 23)
$device
default-device()
- that is the value of $device
or the first one in $devices
$devices
configuration.+column(3, $device: tablet)
, +last-column(1, $device: handheld-320)
$padding
box-sizing: content-box
, it is ensured that you do not break the grid by setting padding or a border.width
attribute of your column (unless you configured $grid-box-sizing: border-box
)padding-top
and padding-bottom
are out of scope - just set them separately.$colspan
, you can also specify a number of columns.+column(5, $padding: 10px)
, +column(10, $padding: 1)
- they will have the same overall width as +column(5)
/ +column(10)
$differing-right-padding
$padding
for the right side or exclusively set $padding
for the right side+column(5, $padding: 10px, $differing-right-padding: 15px)
, +column(5, $differing-right-padding: 10px)
$border-width
$padding
border-width
property when using $grid-box-sizing: border-box
. Otherwise, it also effects the width
property.$differing-right-border-width
$differing-right-padding
$gutter
grid-gutter-width($device)
grid-gutter-width()
is 10px, +column(5, $gutter: 15px)
will just add 5px overall whitespace, not 5*5px.$left-gutter
+column(5, $gutter: 10px, $left-gutter: 10px)
, +last-column($left-gutter: 10px)
$subtract-border-from
+column(10, $padding: 1)
if there wasn't a 1px border that tries to ruin your grid (because you rely on box-sizing: content-box).+column(10, $padding: 1, $border-width: 1px, $subtract-border-from: padding)
instead of +column(10, $padding: 29px, $border-width: 1px)
.padding
, left-padding
, right-padding
, gutter
, left-gutter
, right-gutter
+column(10, $border-width: 2px, $subtract-border-from: gutter)
$grid-box-sizing: border-box
.+grid-container
$device
$colspan
grid-columns($device)
$padding: 0
+grid-container($colspan: 24, $padding: 30px)
still leaves 24 full columns to its content$differing-right-padding
$border-width
$differing-border-width
$left-margin
$padding
.$right-margin
clearfix
overflow
, pie
, pie-clearfix
(same as pie
)$clearfix: pie
if container contents should be visible outside of the container (e.g. when positioned absolutely).There is one. Have a look at it.
See MIT-LICENSE.
FAQs
Unknown package
We found that crispy-grid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.