Skip to content

Instantly share code, notes, and snippets.

@cray0000
Last active December 20, 2015 13:19
Show Gist options
  • Save cray0000/6137583 to your computer and use it in GitHub Desktop.
Save cray0000/6137583 to your computer and use it in GitHub Desktop.
// Mobile-first approach. Usecase is to hide one of columns by default (mobile)
// and show additional info on desktop (when @media is active)
// !! Working version !! Original problem description is in initial commit.
// @media vars:
$media-desktop: min-width 769px
$media-mobile: max-width 768px
.page
+use-grid(100% (1) hide)
+container
.sidebar
display: none
.content
+span(1 omega)
+breakpoint($media-desktop)
+use-grid(98% (4 6) 0.1 hide)
+container
.sidebar
display: block
+span(first 1)
.content
+span(last 1)
@mirisuzanne
Copy link

Two things strike me here:

  1. I'm not sure I understand why this is better than display: none; and display: block; - what "doesn't work" about that? IE6 required an inline display, but I'm not sure that's worth worrying about.

Unrelated:

  1. When the span is full-width (in your initial grid) we really shouldn't be floating, and setting a width. We can easily detect that and do something different. In most cases, you actually don't need anything - block items are full-width by default. Maybe a new layout context, or a new row? clear: all; could work, but may surprise people when they have to remove it somehow.

@cray0000
Copy link
Author

cray0000 commented Aug 2, 2013

Yup, the case was in full-width span.
+span(1) added default gutter of 1/4 which is margin-right: 25%;. And it kept this gutter in grid that overrides the default one.
So if we add omega argument: +span(1 omega) then overriding of it works properly

I think if it's possible to detect that span is taking all of the columns then making omega argument implicit may be a reasonable solution.
Of course your proposition not to float it at all and make use of default full-width of block element is much better. I'm afraid only clear: both; can help to achieve this but as you said it will be more confusing for people to explicitly do clear: none to override it. And adding clear: none into default +span() output will bloat the compiled css too much so it doesn't worth it either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment