mixins.scss 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. @charset "UTF-8";
  2. $phone: "(min-width: 320px) and (max-width: 768px)";
  3. $desktop: "(min-width: 768px)";
  4. $iphonex:'only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3)';
  5. $vari : 750 / 640;
  6. @function px2rem($size){
  7. @return $size / 20 / 2 / $vari + rem;
  8. }
  9. @function -px2rem($size){
  10. @return - $size / 20 / 2 / $vari + rem;
  11. }
  12. @mixin reset{
  13. margin: 0;
  14. padding: 0;
  15. }
  16. @mixin inline-block{
  17. display: inline-block;
  18. *display: inline;
  19. *zoom: 1;
  20. }
  21. @mixin clearfix{
  22. *zoom: 1;
  23. &:before,
  24. &:after{
  25. content: "";
  26. display: table;
  27. line-height: 0;
  28. }
  29. &:after{
  30. clear: both;
  31. }
  32. }
  33. // 弹性盒子webkit-box
  34. @mixin webkitbox( $type : 1 ){
  35. display: -webkit-box;
  36. @if $type == 1{ -webkit-box-orient: horizontal; }//水平
  37. @if $type == 2{ -webkit-box-orient: vertical;flex-direction :column}//垂直
  38. }
  39. @mixin flex($flex){
  40. -webkit-box-flex: $flex;
  41. }
  42. @mixin size($value) {
  43. width: $value;
  44. height: $value;
  45. }
  46. @mixin size($width, $height) {
  47. width: $width;
  48. height: $height;
  49. }
  50. @mixin hide-text{
  51. text-indent: 100%;
  52. white-space: nowrap;
  53. overflow: hidden;
  54. }
  55. @mixin break {
  56. -ms-word-break: break-all;
  57. word-break: break-all;
  58. word-break: break-word;
  59. }
  60. // 文字溢出
  61. @mixin ellipsis {
  62. white-space: nowrap;
  63. overflow: hidden;
  64. -ms-text-overflow: ellipsis;
  65. -o-text-overflow: ellipsis;
  66. text-overflow: ellipsis;
  67. }
  68. @mixin ellipsis-clamp($value){
  69. display: -webkit-box;
  70. -webkit-line-clamp: $value;
  71. -webkit-box-orient: vertical;
  72. overflow: hidden;
  73. text-overflow: ellipsis
  74. }
  75. @mixin pre {
  76. white-space: pre-wrap;
  77. white-space: -moz-pre-wrap;
  78. white-space: -pre-wrap;
  79. white-space: -o-pre-wrap;
  80. word-wrap: break-word;
  81. }
  82. @mixin wrap {
  83. text-wrap: wrap;
  84. white-space: pre-wrap;
  85. white-space: -moz-pre-wrap;
  86. word-wrap: break-word;
  87. }
  88. // http://www.hicss.net/solve-change-line-in-css/
  89. @mixin nowrap {
  90. white-space: nowrap;
  91. word-break: keep-all;
  92. }
  93. @mixin opacity($opacity) {
  94. opacity: $opacity;
  95. filter: alpha(opacity=#{$opacity * 100});
  96. }
  97. @mixin min-height($height) {
  98. min-height: $height;
  99. height: auto !important;
  100. _height: $height;
  101. }
  102. // 旋转
  103. @mixin rotate($value:180deg){
  104. -webkit-transform: rotate($value);
  105. -moz-transform: rotate($value);
  106. -ms-transform: rotate($value);
  107. transform: rotate($value);
  108. }
  109. // css角标
  110. @mixin u-arrow-left($value:6px,$bordercolor:#fff){
  111. border-width: $value;
  112. border-color: transparent $bordercolor transparent transparent;
  113. border-style: solid;
  114. }
  115. // Gradients 添加渐变过渡函数,20140110 add by petsa
  116. @mixin gradient($color-form, $color-to) {
  117. background: $color-form; // Old browsers
  118. background: -moz-linear-gradient(top, $color-form 0%, $color-to 100%); // FF3.6+
  119. background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,$color-form), color-stop(100%,$color-to)); // Chrome,Safari4+
  120. background: -webkit-linear-gradient(top, $color-form 0%, $color-to 100%); // Chrome10+,Safari5.1+
  121. background: -o-linear-gradient(top, $color-form 0%, $color-to 100%); // Opera 11.10+
  122. background: -ms-linear-gradient(top, $color-form 0%, $color-to 100%); // IE10+
  123. background: linear-gradient(to bottom, $color-form 0%, $color-to 100%); // W3C
  124. filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#{$color-form}', endColorstr='#{$color-to}',GradientType=0 ); // IE6-9
  125. }
  126. //三角朝上
  127. @mixin triangle-up($width,$color){
  128. width: 0;
  129. height: 0;
  130. border: $width solid $color;
  131. border-color: transparent transparent $color;
  132. }
  133. //三角朝下
  134. @mixin triangle-down($width,$color){
  135. width: 0;
  136. height: 0;
  137. border: $width solid $color;
  138. border-color: $color transparent transparent;
  139. }
  140. //三角朝左
  141. @mixin triangle-left($width,$color){
  142. width: 0;
  143. height: 0;
  144. border: $width solid $color;
  145. border-color: transparent $color transparent transparent;
  146. }
  147. //三角朝右
  148. @mixin triangle-right($width,$color){
  149. width: 0;
  150. height: 0;
  151. border: $width solid $color;
  152. border-color: transparent transparent transparent $color;
  153. }
  154. //左上三角形
  155. @mixin triangle-topleft($width,$color){
  156. width: 0;
  157. height: 0;
  158. border: $width solid $color;
  159. border-color: $color transparent transparent $color;
  160. }
  161. //右上三角形
  162. @mixin triangle-topright($width,$color){
  163. width: 0;
  164. height: 0;
  165. border: $width solid $color;
  166. border-color: $color $color transparent transparent;
  167. }
  168. //左下三角形
  169. @mixin triangle-bottomleft($width,$color){
  170. width: 0;
  171. height: 0;
  172. border: $width solid $color;
  173. border-color: transparent transparent $color $color;
  174. }
  175. //右下三角形
  176. @mixin triangle-bottomright($width,$color){
  177. width: 0;
  178. height: 0;
  179. border: $width solid $color;
  180. border-color: transparent $color $color transparent;
  181. }