mixins.scss 4.4 KB

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