Created
October 29, 2012 04:49
-
-
Save hiloki/3971588 to your computer and use it in GitHub Desktop.
mq()の引数に指定したキーワードにあわせた値がメディアクエリの条件として適用される。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
# 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; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
only screen が悩ましい。