Skip to content

Instantly share code, notes, and snippets.

@corny
Created April 4, 2012 19:04
Show Gist options
  • Save corny/2304803 to your computer and use it in GitHub Desktop.
Save corny/2304803 to your computer and use it in GitHub Desktop.
bootstrap-sass mixin for responsive designs
// bootstrap-sass mixin for responsive designs
// this mixin requires sass support for content blocks (sass >= 3.2.0)
// Media widths:
// http://twitter.github.com/bootstrap/scaffolding.html#responsive
// https://github.com/digineo/bootstrap-sass/commit/20828376f7cf72ec1ca808633dde186c5682ea97
=respond-to($media)
@if $media == phone
@media only screen and (max-width: $mediaPhone)
@content
@else if $media == tablet
@media only screen and (max-width: $mediaTablet - 1)
@content
@else if $media == portrait
@media only screen and (min-width: $mediaTablet) and (max-width: $mediaDesktop - 1)
@content
@else if $media == desktop
@media only screen and (min-width: $mediaDesktop)
@content
@else if $media == large
@media only screen and (min-width: $mediaLarge)
@content
@corny
Copy link
Author

corny commented Apr 4, 2012

Usage:

.your-selector
  +respond-to(tablet)
    width: 95%
    margin: auto

@thomas-mcdonald
Copy link

This is very cool. I'll see what we can do with it.

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