説明なし

breakpoints.scss 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /**
  2. * Responsive Styles
  3. */
  4. /**
  5. * Required Variables
  6. */
  7. $default_width: 610px;
  8. $max_content_width: 1240px;
  9. $breakpoint_sm: 482px;
  10. $breakpoint_md: 592px;
  11. $breakpoint_lg: 652px;
  12. $breakpoint_xl: 822px;
  13. $breakpoint_xxl: 1024px;
  14. // Responsive breakpoints mixin
  15. @mixin media( $res ) {
  16. @if mobile-only == $res {
  17. @media only screen and (max-width: #{$breakpoint_sm - 1}) {
  18. @content;
  19. }
  20. }
  21. @if mobile == $res {
  22. @media only screen and (min-width: #{$breakpoint_sm}) {
  23. @content;
  24. }
  25. }
  26. @if tablet-only == $res {
  27. @media only screen and (max-width: #{$breakpoint_md - 1}) {
  28. @content;
  29. }
  30. }
  31. @if tablet == $res {
  32. @media only screen and (min-width: #{$breakpoint_md}) {
  33. @content;
  34. }
  35. }
  36. @if laptop-only == $res {
  37. @media only screen and (max-width: #{$breakpoint_lg - 1}) {
  38. @content;
  39. }
  40. }
  41. @if laptop == $res {
  42. @media only screen and (min-width: #{$breakpoint_lg}) {
  43. @content;
  44. }
  45. }
  46. @if desktop-only == $res {
  47. @media only screen and (max-width: #{$breakpoint_xl - 1}) {
  48. @content;
  49. }
  50. }
  51. @if desktop == $res {
  52. @media only screen and (min-width: #{$breakpoint_xl}) {
  53. @content;
  54. }
  55. }
  56. @if wide-only == $res {
  57. @media only screen and (max-width: #{$breakpoint_xxl - 1}) {
  58. @content;
  59. }
  60. }
  61. @if wide == $res {
  62. @media only screen and (min-width: #{$breakpoint_xxl}) {
  63. @content;
  64. }
  65. }
  66. }
  67. /**
  68. * Root Media Query Variables
  69. */
  70. :root {
  71. --responsive--spacing-horizontal: calc(2 * var(--global--spacing-horizontal) * 0.6);
  72. --responsive--aligndefault-width: calc(100vw - var(--responsive--spacing-horizontal));
  73. --responsive--alignwide-width: calc(100vw - var(--responsive--spacing-horizontal));
  74. --responsive--alignfull-width: 100%;
  75. --responsive--alignright-margin: var(--global--spacing-horizontal);
  76. --responsive--alignleft-margin: var(--global--spacing-horizontal);
  77. }
  78. @include media(mobile) {
  79. :root {
  80. --responsive--aligndefault-width: min(calc(100vw - 4 * var(--global--spacing-horizontal)), #{$default_width});
  81. --responsive--alignwide-width: calc(100vw - 4 * var(--global--spacing-horizontal));
  82. --responsive--alignright-margin: calc(0.5 * (100vw - var(--responsive--aligndefault-width)));
  83. --responsive--alignleft-margin: calc(0.5 * (100vw - var(--responsive--aligndefault-width)));
  84. }
  85. }
  86. @include media(desktop) {
  87. :root {
  88. --responsive--aligndefault-width: min(calc(100vw - 8 * var(--global--spacing-horizontal)), #{$default_width});
  89. --responsive--alignwide-width: min(calc(100vw - 8 * var(--global--spacing-horizontal)), #{$max_content_width});
  90. }
  91. }
  92. /**
  93. * Extends
  94. */
  95. %responsive-aligndefault-width {
  96. max-width: var(--responsive--aligndefault-width);
  97. margin-left: auto;
  98. margin-right: auto;
  99. }
  100. %responsive-alignwide-width {
  101. max-width: var(--responsive--alignwide-width);
  102. margin-left: auto;
  103. margin-right: auto;
  104. }
  105. %responsive-alignfull-width-mobile {
  106. max-width: var(--responsive--alignfull-width);
  107. width: var(--responsive--alignfull-width);
  108. margin-left: auto;
  109. margin-right: auto;
  110. }
  111. @include media(mobile) {
  112. %responsive-alignfull-width {
  113. max-width: var(--responsive--alignfull-width);
  114. width: auto;
  115. margin-left: auto;
  116. margin-right: auto;
  117. }
  118. }
  119. %responsive-alignwide-width-nested {
  120. margin-left: auto;
  121. margin-right: auto;
  122. width: var(--responsive--alignwide-width);
  123. max-width: var(--responsive--alignfull-width);
  124. }
  125. %responsive-alignfull-width-nested {
  126. margin-left: auto;
  127. margin-right: auto;
  128. width: calc(var(--responsive--alignfull-width) - calc(2 * var(--responsive--spacing-horizontal)));
  129. max-width: var(--responsive--alignfull-width);
  130. }
  131. @include media(desktop) {
  132. %responsive-alignfull-width-nested {
  133. margin-left: auto;
  134. margin-right: auto;
  135. width: calc(var(--responsive--alignfull-width) - calc(4 * var(--responsive--spacing-horizontal)));
  136. max-width: var(--responsive--alignfull-width);
  137. }
  138. }
  139. %responsive-alignleft-mobile {
  140. /*rtl:ignore*/
  141. margin-left: 0;
  142. /*rtl:ignore*/
  143. margin-right: var(--responsive--spacing-horizontal);
  144. }
  145. @include media(mobile) {
  146. %responsive-alignleft {
  147. /*rtl:ignore*/
  148. margin-left: var(--responsive--alignleft-margin);
  149. /*rtl:ignore*/
  150. margin-right: var(--global--spacing-horizontal);
  151. }
  152. }
  153. %responsive-alignright-mobile {
  154. /*rtl:ignore*/
  155. margin-left: var(--responsive--spacing-horizontal);
  156. /*rtl:ignore*/
  157. margin-right: 0;
  158. }
  159. @include media(mobile) {
  160. %responsive-alignright {
  161. /*rtl:ignore*/
  162. margin-left: var(--global--spacing-horizontal);
  163. /*rtl:ignore*/
  164. margin-right: var(--responsive--alignright-margin);
  165. }
  166. }
  167. // Output
  168. .default-max-width {
  169. @extend %responsive-aligndefault-width;
  170. }
  171. .wide-max-width {
  172. @extend %responsive-alignwide-width;
  173. }
  174. .full-max-width {
  175. @extend %responsive-alignfull-width;
  176. }