mituri

Screen sizes Mobile first

Mar 19th, 2019
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. //*** SCREEN SIZES ***//
  2.  
  3. // 320 - 479 px
  4. $screen-ts-max: 479px;
  5.  
  6. // 480 - 767 px
  7. $screen-xs-min: 480px;
  8. $screen-xs-max: 767px;
  9.  
  10. // 768 - 991 px
  11. $screen-sm-min: 768px;
  12. $screen-sm-max: 991px;
  13.  
  14. // 992 - 1199px
  15. $screen-md-min: 992px;
  16. $screen-md-max: 1199px;
  17.  
  18. // 1200 - inf px
  19. $screen-lg-min: 1200px;
  20.  
  21. // Screen media breakpoints
  22. $screen-ts: "screen and (min-width: 0) and (max-width: #{$screen-ts-max})";
  23. $screen-xs: "screen and (min-width: #{$screen-xs-min}) and (max-width: #{$screen-xs-max})";
  24. $screen-sm: "screen and (min-width: #{$screen-sm-min}) and (max-width: #{$screen-sm-max})";
  25. $screen-md: "screen and (min-width: #{$screen-md-min}) and (max-width: #{$screen-md-max})";
  26. $screen-lg: "screen and (min-width: #{$screen-lg-min})";
  27.  
  28. // Screen media mixin
  29. // How to use? Like this:
  30. //
  31. // @include smMin{
  32. // p{
  33. // color: red;
  34. // }
  35. // }
  36. //
  37. // .class{
  38. // text-align: left;
  39. // @include mdMin{
  40. // text-align: right;
  41. // }
  42. // }
  43. //
  44.  
  45. @mixin respondFromTo ($size_from, $size_to){
  46. @media screen and (min-width: $size_from) and (max-width: $size_to){
  47. @content;
  48. }
  49. }
  50.  
  51. @mixin tsMax {
  52. @media screen and (max-width: #{$screen-ts-max}) {
  53. @content;
  54. }
  55. }
  56.  
  57. @mixin xsMin {
  58. @media screen and (min-width: #{$screen-xs-min}) {
  59. @content;
  60. }
  61. }
  62.  
  63. @mixin xsMax {
  64. @media screen and (max-width: #{$screen-xs-max}) {
  65. @content;
  66. }
  67. }
  68.  
  69. @mixin smMin {
  70. @media screen and (min-width: #{$screen-sm-min}) {
  71. @content;
  72. }
  73. }
  74.  
  75. @mixin smMax {
  76. @media screen and (max-width: #{$screen-sm-max}) {
  77. @content;
  78. }
  79. }
  80.  
  81. @mixin mdMin {
  82. @media screen and (min-width: #{$screen-md-min}) {
  83. @content;
  84. }
  85. }
  86.  
  87. @mixin mdMax {
  88. @media screen and (max-width: #{$screen-md-max}) {
  89. @content;
  90. }
  91. }
  92.  
  93. @mixin lgMin {
  94. @media screen and (min-width: #{$screen-lg-min}) {
  95. @content;
  96. }
  97. }
  98.  
  99. @mixin tsOnly {
  100. @include respondFromTo(0,$screen-ts-max) {
  101. @content;
  102. }
  103. }
  104.  
  105. @mixin xsOnly {
  106. @include respondFromTo($screen-xs-min,$screen-xs-max) {
  107. @content;
  108. }
  109. }
  110.  
  111. @mixin smOnly {
  112. @include respondFromTo($screen-sm-min,$screen-sm-max) {
  113. @content;
  114. }
  115. }
  116.  
  117. @mixin mdOnly {
  118. @include respondFromTo($screen-md-min,$screen-md-max) {
  119. @content;
  120. }
  121. }
  122.  
  123. @mixin lgOnly {
  124. @media #{ $screen-lg } {
  125. @content;
  126. }
  127. }
  128.  
  129.  
  130. // BOOTSTRAP CONTAINER 970PX;
  131. .container {
  132. @include lgMin {
  133. width: 970px;
  134. }
  135. }
  136.  
  137. // Retina media query
  138. @mixin retinaDisplay {
  139. @media only screen and (-webkit-min-device-pixel-ratio: 1.5),
  140. only screen and (-o-min-device-pixel-ratio: 3/2),
  141. only screen and (min--moz-device-pixel-ratio: 1.5),
  142. only screen and (min-device-pixel-ratio: 1.5) {
  143. @content
  144. }
  145. }
Advertisement
Add Comment
Please, Sign In to add comment