.heading은 .frame에 속하지 않게 된다.
scss
css
html
<header>
<h1>Headline Text in header</h1>
</header>
<section>
<h1>Headline Text in section</h1>
</section>
<footer>
<h1>Headline Text in footer</h1>
</footer>
scss
:is(header,section,footer) h1 {
font-size: 30px;
font-weight: normal;
}
scss imort
@import "reset"; // 확장자 생략 가능
혹은
@import ("reset.scss"); // scss파일만 import 가능
css import
@import url("reset.css");
기본 문법
@mixin default {
font-family: 'Raleway', sans-serif;
font-size: 15px;
margin: 0;
color: #333;
background-color: #fff;
line-height: 1.6em;
}
body {
@inlcude default;
}
mixin만 따로 외부파일로 선언해서 import도 가능
// mixin.scss
@mixin default {
font-family: 'Raleway', sans-serif;
font-size: 15px;
margin: 0;
color: #333;
background-color: #fff;
line-height: 1.6em;
}
// style.scss
@import "mixin";
body {
@include default;
}
%로 정의한 속성을 @extend 해서 재사용 할 수 있다.
%shape {
width: 250px;
height: 300px;
border-radius: 5px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.212);
}
.card {
display: flex;
gap: 30px;
&-item {
@extend %shape;
display: flex;
justify-content: center;
align-items: center;
}
}
변수를 객체처럼 선언하고 map-get으로 호출한다.
@for $i from 1 through length($colors)
js로 해석하자면 for (let i=1; i<=colors.length; i++)
와 같다.
&:nth-child(#{$i})
이부분에서 #{}
는 변수 $i
를 받기 위한 키워드이다.
$colors: (red, orange, yellow, green, blue, indigo, purple);
ul {
list-style: none;
padding: 0;
li {
width: 100px;
height: 20px;
@for $i from 1 through length($colors) {
&:nth-child(#{$i}) {
background-color: nth($colors, $i);
}
}
}
}
lighten(색깔, 퍼센트)
색깔을 퍼센트만큼 밝게 하거나 어둡게 한다