index.scss 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. $aa: blue;
  2. $bb: 2px solid #f00;
  3. $cc: 400 !default;
  4. // $dd: purple !global;
  5. $dd: purple !important;
  6. // 这是h2标签的样式
  7. /* 哈哈哈哈 */
  8. // @import url(reset.css);
  9. @import './reset.scss';
  10. h2 {
  11. width: $cc + px;
  12. height: 300px;
  13. color: $dd;
  14. color: $aa;
  15. border: $bb;
  16. }
  17. ul {
  18. li {
  19. color: red;
  20. &:first-child {
  21. color: #0f0;
  22. }
  23. font: {
  24. size: 40px;
  25. weight: bold;
  26. };
  27. }
  28. }
  29. // 不带参的混合宏
  30. // @mixin x {
  31. // color: #f00;
  32. // background: #ff0;
  33. // border-radius: 20px;
  34. // }
  35. // .one {
  36. // width: $cc + px;
  37. // height: $cc + px;
  38. // @include x;
  39. // }
  40. // 带参混合宏
  41. // (带参 不带值)
  42. // @mixin x($cccc) {
  43. // color: #f00;
  44. // background: #ff0;
  45. // border-radius: $cccc + px;
  46. // }
  47. // .one {
  48. // width: $cc + px;
  49. // height: $cc + px;
  50. // @include x(50);
  51. // }
  52. // // (带参 带值)
  53. // @mixin x($cccc:50%) {
  54. // color: #f00;
  55. // background: #ff0;
  56. // border-radius: $cccc;
  57. // }
  58. // .one {
  59. // width: $cc + px;
  60. // height: $cc + px;
  61. // @include x;
  62. // }
  63. // 带参 多值
  64. // @mixin x($c...) {
  65. // color: #f00;
  66. // background: #ff0;
  67. // border-radius: 20px;
  68. // box-shadow: $c;
  69. // }
  70. // .one {
  71. // width: $cc + px;
  72. // height: $cc + px;
  73. // @include x(55px 40px 30px blue);
  74. // }
  75. // 继承
  76. // 基类
  77. // .vase {
  78. // font-size: 30px;
  79. // color: #0f0;
  80. // }
  81. // .one {
  82. // width: $cc + px;
  83. // height: $cc + px;
  84. // @extend .vase;
  85. // }
  86. // 占位符
  87. // %
  88. %yy {
  89. color: #f00;
  90. font-style: italic;
  91. font-weight: 700;
  92. }
  93. // 函数
  94. @function getWidth($x) {
  95. @return $x * 2;
  96. }
  97. /*
  98. 声明:
  99. @function xx(形参) {
  100. @return 表达式;
  101. }
  102. 使用:
  103. #{函数名(实参)}
  104. */
  105. .one {
  106. width: #{getWidth(300)}px;
  107. // height: 300px+200px; 单位统一
  108. // height: 600px - 300px; 减法前后加空格
  109. // height: 300px * 2; 只允许一个数值有单位
  110. height: (600px/2); //需要添加括号
  111. // @extend %yy;
  112. color: #0ff + #ff0; //分段运算
  113. border: 2px solid #00f;
  114. }