index.scss 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // @import url(reset.css);
  2. @import './reset.scss';
  3. $a: #ff0;
  4. $b: 70 !default;
  5. /*
  6. 混合宏
  7. @mixin 定义一个可以在整个样式表中重复使用的样式
  8. @include 调用
  9. */
  10. @mixin aaa {
  11. // border-radius: 20px;
  12. border: 3px solid #00f;
  13. }
  14. @mixin bbb($x) {
  15. border-radius: $x;
  16. }
  17. @mixin ccc($w:500px, $h:500px) {
  18. width: $w;
  19. height: $h;
  20. }
  21. @mixin ddd($q...) {
  22. box-shadow: $q;
  23. }
  24. @function size($p) {
  25. @return $p * 4;
  26. }
  27. // 继承
  28. .vase {
  29. font-size: 26px;
  30. color: plum
  31. }
  32. // 占位符
  33. %www {
  34. color: red;
  35. font-style: italic
  36. }
  37. .box {
  38. // @extend .vase;
  39. // @include aaa;
  40. width: #{size(100)}px;
  41. // height: 400px - 100px;
  42. // height: 100px + 300px;
  43. // height: 100px * 6;
  44. height: (1000px / 2);
  45. background: #00f + #ff0;
  46. @include bbb(50px);
  47. // @include ccc;
  48. @include ddd(5px 10px 10px red);
  49. b {
  50. // @extend %www;
  51. }
  52. p {
  53. // @extend .vase;
  54. }
  55. h1 {
  56. color: $a;
  57. font-size: $b + px;
  58. $c: red !global;
  59. }
  60. // 这是一条注释 单行注释 编译后不会出现在css中
  61. /* 多行注释 编译后会出现在css中 */
  62. // 嵌套 选择器嵌套
  63. ul {
  64. li {
  65. a {
  66. color: $c;
  67. // font-size: 20px;
  68. // font-style: italic;
  69. // 属性嵌套
  70. font: {
  71. size: 30px;
  72. style: italic;
  73. }
  74. // 伪类嵌套
  75. &:hover {
  76. color: #ff0;
  77. }
  78. }
  79. }
  80. }
  81. }