Skip to content

Instantly share code, notes, and snippets.

@wfendler
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wfendler/68a57a53cf6d7b84605f to your computer and use it in GitHub Desktop.
Save wfendler/68a57a53cf6d7b84605f to your computer and use it in GitHub Desktop.
Divvy media query implementation
.box {
// base/"mobile" styles
}
.box--within--hand {
@include media-query($BP--WITHIN--HAND) {
// |---hand---| styles
}
}
.box--starts-at--hand {
@include media-query($BP--STARTS_AT--HAND) {
// |---hand---> styles
}
}
.box--ends-at--hand {
@include media-query($BP--ENDS_AT--HAND) {
// <---hand---| styles
}
}
@mixin media-query ($MQ) {
@media only screen and #{$MQ} {
@content;
}
}
$VIEWPORT--HAND_START: 320px;
$VIEWPORT--HAND_END: 480px;
$VIEWPORT--LAP_START: $VIEWPORT--HAND_END + 1px;
$VIEWPORT--LAP_END: 768px;
$VIEWPORT--DESK_START: $VIEWPORT--LAP_END + 1px;
$VIEWPORT--DESK_END: 1400px;
$BP--WITHIN--HAND: "(min-width: #{$VIEWPORT--HAND_START}) and (max-width: #{$VIEWPORT--HAND_END})";
$BP--STARTS_AT--HAND: "(min-width: #{$VIEWPORT--HAND_START})";
$BP--ENDS_AT--HAND: "(max-width: #{$VIEWPORT--HAND_END})";
$BP--WITHIN--LAP: "(min-width: #{$VIEWPORT--LAP_START}) and (max-width: #{$VIEWPORT--LAP_END})";
$BP--STARTS_AT--LAP: "(min-width: #{$VIEWPORT--LAP_START})";
$BP--ENDS_AT--LAP: "(max-width: #{$VIEWPORT--LAP_END})";
$BP--WITHIN--DESK: "(min-width: #{$VIEWPORT--DESK_START}) and (max-width: #{$VIEWPORT--DESK_END})";
$BP--STARTS_AT--DESK: "(min-width: #{$VIEWPORT--DESK_START})";
$BP--ENDS_AT--DESK: "(max-width: #{$VIEWPORT--DESK_END})";
// We could also end up doing stuff like:
// $BP--PORTRAIT: (orientation:portrait);
// $BP--LANDSCAPE: (orientation:landscape);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment