sassbourbonneat

Using custom media queries with Neat


The documentation grid-media on Neat 2.0.0 describes the ability to set a media query in pixels. By default, this will output a pixel value as a min-width media query.

For example:

$custom-neat-grid: (
  columns: 12,
  gutter: 50px,
  media: 1000px,
);

.element {
  @include grid-column(3);

  @include grid-media($custom-neat-grid){
    @include grid-column(6);
  }
}

will output to:

.element {
  width: calc(25% - 25px);
  float: left;
  margin-left: 20px;
}

@media only screen and (min-width: 1000px) {
  .element {
    width: calc(50% - 75px);
    float: left;
    margin-left: 50px;
  }
}

How can I use grid-media in Neat with other media query attributes like max-width or height?


Solution

  • I worked out how to achieve this.

    You can pass a full media query to the media parameter of a custom grid.

    An example:

    $custom-neat-grid: (
      columns: 12,
      gutter: 50px,
      media: 'only screen and (max-width: 600px)',
    );