Skip to content

Instantly share code, notes, and snippets.

@hiloki
Created October 29, 2012 04:49
Show Gist options
  • Save hiloki/3971588 to your computer and use it in GitHub Desktop.
Save hiloki/3971588 to your computer and use it in GitHub Desktop.
mq()の引数に指定したキーワードにあわせた値がメディアクエリの条件として適用される。
/*
# Short Mediaqueries
mq()の引数に指定したキーワードにあわせた値がメディアクエリの条件として適用される。
- handheld = min-width: 480px
- tablet = min-width: 768px
- desktop = min-width: 960px
上記に該当しない条件を適用したい場合には、引数に任意の条件を記述する。
``` CSS
.container {
width: 95%;
@include mq(iphone) { width: 90%; }
@include mq(ipad) { width: 80%; }
@include mq(desktop) { width: 70%; }
@include mq(min-width: 1280px) { width: 100%; }
}
```
...
*/
@mixin mq($media) {
@if $media == handheld {
@media only screen and (min-width: 480px) { @content; }
}
@else if $media == tablet {
@media only screen and (min-width: 768px) { @content; }
}
@else if $media == desktop {
@media only screen and (min-width: 960px) { @content; }
}
@else {
@media only screen and #{$media} { @content; }
}
}
@hiloki
Copy link
Author

hiloki commented Oct 29, 2012

only screen が悩ましい。

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