<h1 class="heading">Codingworks <span>Publishing</span> class</h1>
@mixin headline {
text-align: center;
font-size: 36px;
text-transform: capitalize;
position: relative;
padding-bottom: 20px;
span {
color: royalblue;
}
&::before {
content: '';
position: absolute;
width: 100px;
height: 4px;
background-color: crimson;
bottom: 0;
left: 50%;
transform: translateX(-50%);
}
}
.heading {
@include headline();
}
<h1 class="heading">Codingworks <span>Publishing</span> class</h1>
<h1 class="news-headline">
news <span>headline</span> broadcast
</h1>
.heading {
@include headline();
}
.news-headline {
@include headline();
}
body {
@include default;
}
@mixin default {
font-family: "Raleway", sans-serif;
font-size: 15px;
margin: 0;
color: #333;
background-color: #fff;
line-height: 1.6em;
}
이렇게 @mixin 선언이 @include 사용보다 밑에 있다면 적용되지않는다. @mixin 선언은 맨위에서 해놓는게 좋은방법이다.
@mixin 선언은 프로젝트 크기가 커지면 커질수록 많아질것이다. 따로 scss폴더를 만들자
mixin.scss
@mixin default {
font-family: "Raleway", sans-serif;
font-size: 15px;
margin: 0;
color: #333;
background-color: #fff;
line-height: 1.6em;
}
@mixin headline {
text-align: center;
font-size: 36px;
text-transform: capitalize;
position: relative;
padding-bottom: 20px;
span {
color: royalblue;
}
&::before {
content: '';
position: absolute;
width: 100px;
height: 4px;
background-color: crimson;
bottom: 0;
left: 50%;
transform: translateX(-50%);
}
}
@import "mixin";
* {
font-family: "Raleway", sans-serif;
box-sizing: border-box;
outline: none;
}
body {
@include default;
}
.heading {
@include headline;
}
.news-headline {
@include headline;
}
<div class="buttons">
<button class="approval">승인</button>
<button class="refuse">거절</button>
</div>
//Buttons Mixin
@mixin border-style($width, $style, $color) {
border: $width $style $color;
}
@mixin button-padding($updown, $leftright) {
padding: $updown $leftright;
}
,
넣지않도록 주의하기.buttons {
button {
// width: 200px;
padding: 7px;
background-color: #fff;
outline: none;
cursor: pointer;
font-size: 18px;
@include button-padding(20px, 150px);
&.approval {
@include border-style(5px, solid, red);
}
&.refuse {
@include border-style(5px, dashed, royalblue);
}
}
}
,
로 구분