SCSS 장점

문법

변수


$font-stack: Helvetica, sans-serif;
$primary-color: #333;

body {
  font: 100% $font-stack;
  color: $primary-color;
}

중첩

nav {
  ul {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  li { display: inline-block; }

  a {
    display: block;
    padding: 6px 12px;
    text-decoration: none;
  }
}

재활용(Mixins)

//선언 @mixin
@mixin center {
  display: flex;
  justify-content: center;
  align-items: center;
}
//사용 @include
.container {
  @include center;
  .box {
		 @include center;
	 }
}

@mixin theme($theme: DarkGray,$color:#fff) {
// 함수처럼 매개변수 받아서 사용가능. (a,b)여러개 지정가능
// :DarkGray를 사용하여 $theme의 기본값 설정
  background: $theme;
  box-shadow: 0 0 1px rgba($theme, .25);
  color: $color;
}

.info {
  @include theme; 
}
//.alert {
//  @include theme(DarkRed,#000);
//}
.alert {
  @include theme($theme: DarkRed); //"$theme:"을 사용하여 전달값 지정가능.
}
.success {
  @include theme($color: green);
}